Hello World

Bryan Cairns
A free video tutorial from Bryan Cairns
Computer Guru
4.4 instructor rating • 15 courses • 140,586 students

Learn more from the full course

Qt 5 Core for Beginners with C++

No experience necessary, learn Qt C++ cross platform programming on windows, mac and linux for beginners using Qt 5.

08:20:16 of on-demand video • Updated December 2020

  • C++ for beginners
  • C++ programming
  • Qt
  • Qt 5 Core
  • Variables
  • Scope
  • Pointers
  • QObject
  • Command line programs
  • Input and output
  • Flow control
  • Functions
  • Signals and slots
  • Casting
  • Error handling
  • Templates
  • QString class
  • QList class
  • QVariant class
  • QT Creator
  • Cross Platform Development
English [Auto] Go ahead and make a new project we're going to choose Q console application we're going to give it a name and this is cute core for beginners or in section 1 video 5 and we want to create it in this folder. You can click Browse and put in any folder you want and you can even say use default meaning this will always be the location by default every time you make a new project going to next built system leave it as make. Even though there are other options we're going to be going over make kit selection. This is where I get a ton of mail. Selection is extremely easy to understand but it's very deceiving. Kit selection is the platform you want to deploy on. Notice how I have the desktop checked but also have Android in here. You might not have Android listed you may even have other options. Point is make sure desktop is checked because that's what we're developing on and that's what we want to deploy too. If we were doing Android programming we'd have Android in here if you were Mac you may see something different windows you may see something different just make sure it says desktop version control. We're not going to use any but you could add in version control if you really wanted to and click Finish or a couple of things happen in the background. Here you see how we've got some breakpoints just going to clear those out. And we've got a project file project files pretty interesting what it says is we are not using the graphic user interface. That's the minus equals the configuration we are using the C++ Levan and cons.. And we're not using an app bundle. Notice how it's plus equals or minus equals for adding and subtracting. I wouldn't really recommend you go in and play around with the project file too much. One thing you want to really look at is sources as you add more files to your project. You'll see more sources in there. It's good close that. And here is our application. In all of its splendor and I realize it's pretty bare. But if you're brand new to programming this may look like some foreign language. This is what's really going on pounde include what that means is this is a compiler directive. We're saying hey we want to include and we want to include that file int main and then some gobbledygook. What does this mean. Main is the starting point for any C++ application where returning it nature which is just a number and when the application starts it's getting some arguments Q.. Core application notices this thing right here. Means we're actually creating an instance of this named as a variable and we're passing these arguments over to it. Return a dot exec. What does that mean. Return means we're returning this value here and we're using 8. exact as this object here. I know this is very confusing and we're going to cover all of this. If you're completely lost. Take a deep breath and just understand we're going to go over it. But anyways eight out exact So we're just returning a number. We're going to do the obligatory hello world and we're just going to include and we want the Q debug. You notice this little thing pops down. That's called Intellisense and this is a lifesaver you're going to love this. You can either type it out or you can just select it from a list. We're going to include Q debug included bug. There's a function called Q info which just lets us print things out so we're going to say hello world. We're going to save it and let's go ahead and run this. Now that happened very quickly but a few things happened you notice this progress bar that's our built status then application output lit up and compile up lit up. We also have a terminal says hello world. Your screen may be a little different you may actually see the hello world down here. That's dependent on how your project is actually set up and you may actually have to google on how to set this up and how to make it run the way you want it. See how it be run it's run in terminal. If that's not checked it'll run right in the ID OK. Let's go back to it and you can see our compile output. There was a lot to happen in the background here what we're doing here is we're essentially taking these files and we're running something called Q make says Q make all and we're taking those files and crunching them into objects meaning we're turning it into machine language. And what's really happening is this object here is being created may not know is being created from made us GPP we can go in here and see this is our directory where we put our code. See there's our code and a new directory is created. You see how it's blah blah blah blah blah blah blah blah blah blah. Sixty four dash debug because we're in debug mode over here cracking this open you see there's our main object our Makefile and our actual program our program is 331 kilobytes in size. That's pretty chunky for small applications like this. Let's go back out here and let's change this from debug to release. I want to talk very briefly about the difference between the two. Notice how nothing in our code is actually changed and when we run this the same application pops up. But we actually have two versions of this running now. Ones and debug ones and release. Let's close both of these and talk about this what just happened. Well you can see now we have two folders a debug and release debug is 331 and release is 13 vastly smaller than the de-bug So what's really going on under the hood the debug version has debug symbols in it. So if you want to run your application and see what's going on under the hood and real time use the debug version however it gets pretty complex. For example if we want to put a break point we just simply click on the line we want the application to stop and we can go ahead and click this little debug icon. Notice how we had a problem. This does not seem to be a debug build. So everything's going to be ignored. And that's because we're in release. So let's switch to debug may take just a second for it to parse it. There we go. And let's kill this and let's rerun it. So what's really going on you know is how you didn't see your application pop up and it's right here but nothing's actually printed on the screen yet. That's because this little yellow arrow is stopped at that red breakpoint on line 9 right there. So before this is executed it's a break point it stops gives you argument inspector so you can see there's our object here which is actually this guy. The core application and we have arguments won arguments to which are these guys here in here. We can also see where our breakpoints are and where we are in the file. You can see how it is vastly unhelpful for the newbie and we're just a step right over that when we do. You notice how Bang's suddenly hello world executed but our applications stopped right here. That's called using breakpoints and you may see that in other videos it can be very helpful and it can be very very confusing. We're probably going to stay away from this just because of how confusing it is. I may use it once or twice but I want you to understand the fundamental difference between running and debugging. We're currently debugging and you can tell because we have all this stuff on the screen and we have that little debug icon. So let's go ahead and kill this and you know how you can run and the debug stuff still stays up even though we're not debugging. That's also very confusing. You just simply click on at it. That all goes away if you want to go back you can go to debug and back and forth. So we can run. There we go. Close that. And if you accidentally hit debug it will flip you into debug mode. So just understand that those things exist. I'm going to go ahead and clear those breakpoints by clicking on them and say my work.