Have you been waiting for a cross-platform application framework for C++ that lets you do everything from creating daemons to writing elegant desktop GUIs? Wait no more. Get up to speed quickly on the Qt Framework using a real world example. This course will teach you both critical portions of the Qt Framework, and how to use the tools that come with the framework including the very powerful Qt Creator IDE. By the end of this course, you'll be comfortable building GUI front ends for the desktop as well as learning how to work with JSON data files and the Networking components of Qt. You'll also become a pro at using the signals and slots mechanism for communicating between classes and processes. This course expects you to already know the C++ programming language.
Overview Welcome to Introduction to Qt: A C++ Cross Platform Application Framework. My name is Tod Gentille and I promise you in future modules I'm just going to start referring to this course as Introduction to Qt. In my experience, the Qt framework is most commonly pronounced cute. This is a little too cute for my case, but I'm getting used to it. You can also call it Q-T, but if you say it too fast it comes out cutie, which is just going too far. I'm calling it Qt throughout this course. You will find that once you start referring to some newer features like Qt quick, the monosyllabic approach does have a certain usefulness. Now you know how to pronounce it, but what is it? I'm going to take most of this module to answer that, but in broad strokes it's a set of comprehensive C++ libraries. I find it particularly helpful at creating desktop GUI applications, but it's certainly not limited to that function.
Getting Started Welcome to the Getting Started module of the Introduction to Qt course. My name is Tod Gentille. In this module we're going to walk through downloading and installing the Qt developer tools, including the Qt Creator IDE. I'm also going to go through the steps for getting a compatible Toolchain installed. Now you may not need to follow along with these steps if you can already compile programs with C++ on your computer. For instance, if you have the C++ compiler from Visual Studio, the Qt installation will find that and automatically configure it for use. The same is true for other Toolchains like MinGW. Just to stay on the open source side of things, I'll be downloading MinGW and doing my demonstrations with the Gnu Compiler Collection. If you use Mac or Linux, I'll be doing separate installation demos for those platforms. On Linux we'll again use gcc. On the Mac we'll take advantage of the developer tool supplied by Apple, namely X Code.
Qt Creator Overview You don't have to use the Qt Creator IDE for Qt development, however, it has a lot of functionality geared towards Qt development and if you're new to Qt this is where you should start and this is what we'll be using in this course. If you're a Vim user, you'll be happy to know there is an option to use Vim-style editing. We're going to start with a 10, 000 ft view of the IDE. If you've seen my courses on eclipse, you know I can talk about IDEs for hours, but I promise not to. I can't cover everything this IDE can do upfront, but we can get an overview. We'll be exploring more as we develop an application, but I wanted to give you some terms and show you where some critical items are. Let's jump right into a demo.
Hello World Revisited Welcome to the Hello World Revisited module of the Introduction to Qt course. My name is Tod Gentille and I know that Hello World can be pretty boring, but sometimes code can just be distracting and get in the way. I'm going to cover some very basic Qt concepts in this module. We'll start with another Hello World console app. This time we'll start doing things in a way that leverages just a tiny bit of Qt. We'll look at some messaging tools in the QtGlobal area and, in particular, we'll use qWarning. Since we'll have a project, we can take a look at the simple. pro file that was created for us and we can see what's available in the projects mode. We'll then move onto yet another console app. I know, beating a dead horse and all that. I want to show how you can use qWarning as a stream. Then I want to show you the fundamental string class in Qt, QString. I'll also give a shout out to the qPrintable function, which can make your life a little simpler. Finally, we'll take a look at using QTextStream for console output. Then, we'll take a farewell look at console applications. While things are still straightforward, I wanted to let you know that if you start thinking of localization right away, you can save yourself from having to revisit your code. We'll look at the tr method that's part of QObject. Then I think it's valuable to see a walkthrough of how to complete the translation process. We'll look at the steps involved which include: loading the translation file and installing the QTranslator, Telling QMake about our translation files, installing and using Qt Linguist, and finally, producing the translated output in our application. Finally, we'll do one last Hello World example, but this time we'll delve into the Qt GUI world. We'll take a look at the structure of what gets created for us and we'll start looking at how we can customize the GUI to fit our needs. Let's get started with the first demo.
VFP Getting Started - The Setup Tab View Welcome to the VFP Getting Started module of the Introduction to Qt course. My name is Tod Gentille. We have a couple of preliminary steps to take first in this module but then we're going to dig into coding. We'll create a new project but then I want to reorganize the folders a little differently from the default and show you the steps you need to take to get everything to build again once you move the files around. Once that's out of the way I want to show you a not-so-obvious trick that lets you bend the IDE to your will. I have ways that I like to code and the default Qt wizards don't conform to that method. Luckily modifying the wizards is just a matter of writing some XML and creating your own. CPPN. H template files. I'm not going to teach you all the ins and outs of doing this. It's pretty easy to figure out once you know it can be done; you just need to look at some examples. I'm going to give you a new wizard that I'll be using when creating new classes in this course. I made the wizard pretty flexible so you can pick and choose the features you want to use. Once we've done that we'll return to C++, well at least to a generated C++, as we start creating the view portion of our application. Let's get started.
VFP - The Model Welcome to the VFP Building the Model module of the Introduction to Qt course. My name is Tod Gentille and in this part we will be writing some C++ code to create the model portions of our project. We're going to break the model down into four classes. One for all of our settings which will be stored in a text file. One that wraps a low-level Tcp socket with the calls we need to make use of that socket. And one that models the instrument. This class would exist even if we had an actual instrument. We still need a software representation of that instrument so that we can communicate with it. The only difference here will be that we'll be sending commands to an Echo server instead of a real instrument. Finally we'll have a provider class whose purpose is to just serve up a class as a singleton. In our project we'll only be treating the settings class as a singleton but the technique is generally useful so I'm including this class. Let's get started on the settings class.
VFP - The View Manager Welcome to the VFP Building the View Manager module of the Introduction to Qt course. My name is Tod Gentille, and in this part we'll be writing the C++ code that ties together our View and our Model, and makes things functional. As a reminder, the point of the View Manager is to mediate between the Model and the View. Using this class accomplishes a couple of things. First, it keeps logic in our View to a bare minimum. Second, it kept the Model from needing to know anything about the View. Third, it keeps the View from needing to know anything about the Model. Finally, it will make long-term maintenance of our code easier. This application is not going to be that large so this might seem like overkill but once you get used to using this and similar design patterns, like MVVM, it becomes second nature to use them and any maintenance programmer familiar with the pattern will be able to get up to speed on your code more quickly. The View Manager is going to just slightly violate the single responsibility principle and will achieve two goals here. The View Manager will both leverage our settings data to properly configure our Model and it will serve as the conduit between the View and the Model. In an app of this size I think this is perfectly acceptable. Somehow I miraculously knew which methods and members I was going to need in each Model class. We'll be developing our View Manager module a little bit differently than our Model modules. We can let the View itself iteratively drive the development of our View Manager. Let's get started.
Menus and Actions Welcome to the Menus and Actions module of the Introduction to Qt course. My name is Tod Gentille, and in this part we'll be adding the finishing touches to our application. We're almost done and that proverbial light is visible at the end of the tunnel. I hope at this point you have a good feel for how to use the Qt framework, and an understanding of just how much it offers the C++ programmer. If you've enjoyed this course I want to take this opportunity to encourage you to rate the course. If you didn't like the course, well, I'm not sure why you made it this far but you did so you should rate the course also. Please feel free to ask questions or provide constructive criticism using the discussion board for this course. I apologize if I didn't cover the portion of Qt that you desperately need to get your job done but I'm hoping to do more Qt courses in the future so again, use the discussion board if there are specific topics you want to see covered. We still have some work to do though. We need to look at how to populate the Menu Bar that was automatically added to our application. We'll see how to use the Action Editor for the Menu Bar. Then we'll leverage those actions in a toolbar and learn how to manipulate the look of the toolbar. We'll also add a new dialog to our app, an About Box, but before we do all that I'm going to get you started, that's right started, on the Control Tab. I know I really only cement my learning in programming by doing. I encourage you to go ahead and try to add the new pieces you need for the Control Tab right now before watching the next clip. If you run into problems you can always stop and watch. If you don't have any problems you might find it instructive to compare how you did to how I did it. I'm only going to get as far as creating the one spinner control for the pulse width, and making it work. You too can stop after getting that far and come back to watch. But when you're done watching the course I highly encourage you to spend some time to finish off the application. We'll also be discovering a few more tips and tricks as we go along and I'm sure we'll run across some more compiler errors. It's time to code.