 Hey everybody, it's Brian and let's dive into learning Qt 6. This is a very, I'll try to keep it brief, introduction into what we're doing and why, and then we'll jump ahead and do some code. Qt 6, or I should say the version 6 of Qt has been released and everybody's diving in. It is completely awesome. It is almost everything I'd hoped for and they're adding new features almost weekly, it seems like. That being said, if you scroll down, you see I am now doing it on a per episode basis. I'm going to try and update it fairly regularly. And the first video was installing on Linux Mac and Windows that drives the other fundamental concept home is it doesn't really matter which operating system you're working on. You should be able to follow these videos just fine. Other thing I want to mention, if you go into my YouTube channel and go down to playlists, I have all the older videos, Qt C++ programming, 224 videos, and they are old. They're ancient, but I'm still getting comments going, hey, this video is a decade old and it's still relevant. So you can really expect Qt to stay on the test of time, but I'm going to stop updating that playlist and instead, and I got a lot of playlists, I should probably prune some of these back, but I'm going to update this Qt 6 with C++ so you could expect to see this one grow. I'll no longer be updating the old one. That being said, what are we going to cover and why? Well, I put a poll out there and there was outstanding requests that we start from scratch. So we're going to be starting with the obligatory hello world just to walk right through the very beginning of this. And real quick before we dive in, if you're following me out on udemy.com or you signed up for one of these courses, I am in the process of rerecording all of these in Qt 6. You know how they all say Qt 5, Qt 5, Qt 5, blah, blah, blah. All of these are going to get redone with Qt 6. It rerecords. This is not just me changing a few little things. It's starting over from scratch and rerecording everything. I'm actually most of the way through rerecording this one right here, the Qt core for beginners. It's been actually fun. I like a lot of the changes they've done with Qt. So without further ado, let's just dive right in. All right, before we dive in, the only assumptions we're really making is that you have Qt creator installed. I really covered that in a previous video and you have some fundamental C++. I don't expect you to be a guru. Just know what a variability is kind of thing. Now, in case Hello World, which is what we're going to cover, is way too fundamental for you. There's this examples tab out here and they have literally tons and tons and tons of examples baked right into Qt creator, the IDE. So feel free to explore those. I get a lot of emails going, how do I scale an image or make a coffee machine or make a HTTP client? It's pretty much all baked right in there. So we're just going to go to projects. We're going to say new, application, Qt console application. Now, in case you're very, very new to Qt, what is a widgets application? And then what's all this stuff? So application, it's a bit misleading, but they're all applications. Unless you're doing a library, which is shareable code between applications. But widgets is, well, what you're looking at literally on the screen. Qt creator is built with Qt widgets. Very cool. We are going to get there eventually, but we have to start somewhere. So we're going to do a console application. If you don't know what a console is, you should probably go to Google, but it looks like this. It's just a console you can type into. Now, in case you're wondering what Qt Qt is, well, it's their newer graphical user interface. This thing runs on everything. And its foundations, of course, is C++, which is why we're starting here at our humble little console. So let's just go to next. And then let's call this Qt6. And this is episode three. Put it wherever you want to on your computer and hit next. Build system is a little bit confusing, especially if you're newbie. But basically, this is how your computer knows how to take the source code and build it, compile it into an actual application. We're going to use CMake in these videos. This is a departure from the previous videos where we've used Qmake. The difference between the two is that Qmake is Qt's proprietary build system. A lot of things in Qt were created because when they were created, there was no alternative or the alternatives were just horrible. So they built their own build system. They're switching over to CMake, so we are as well. CMake has kind of become the industry standard here. We're going to hit next. And translation file, we're not going to really worry about this, but if you want to translate it into another language, you could add a translation file. Again, I'm not going to worry about it right now. Now Qt selection, what is a Qt? Well, a Qt tells how to build, and then you have different types of build, like debug, that's for developers. It's when you want to build it, but it's got bugs in it. That's why it's called debugging. And you want to make sure that you can find those bugs and fix them very quickly. Release is what you would compile and build before you handed it to the end user. And then release with debug information, a little bit more advanced. And then minimum size release, this is pretty cool. It actually squeezes that executable down as small as it can. And then project management, we're not going to really use any version control, but if you are, you just hit configure and then figure it out from there. It's not super hard. And here we go. This is our project in all of its glory. All right, we've got our application. And if you're used to normal C++, this looks a little weird at first glance. We're going to do Hello World, but we're going to do it slightly differently. So you'll notice we're including Qt Core application. And then we have a QCore application with a and then some arguments here. And these arguments are passed via the main. And then we're going a dot exec. So there's a couple of things happening here. First off, we're making a QCore application, shocking, I know. But really what that does is it provides an event loop for the application without a user interface. And we're entering that event loop here. So we can do some sort of action code here, it'll execute that code and then it'll go into the event loop, which keeps our application alive. Just kind of demonstrate that you can build this and assuming your kits are all set up correctly, you'll get a good build because we really haven't done anything. And then you can either run or start debugging. Start debugging is going to be a little bit slow on my virtual machine. So I'm just going to run and it will pop up in this blank screen. Do you notice how it doesn't say return to exit, it's just running this little cursor blinking means it's still running in the background. That's the event loop I'm talking about here. That is what keeps your application alive until you forcefully close it. Once you understand that concept, Qt is actually pretty straightforward. Let's go ahead and make hello world the C++ way. We're going to go here and we need to do an include, so I'm going to include bio stream and I'm going to include string just in case we need it. We really don't. But just in case. We're going to go ahead and make this a function. So if you have no idea what a function is or what IO stream or string is, you really need to go back to enter to C++ land and then pick up the series because we're not going to cover C++. We're only going to cover Qt in this video series. We're going to sprinkle some C++ in there when we talk about fundamental concepts but at its core, we're talking about Qt. So is a new C++ case you're wondering, there's tons and tons of playlists out on Google and YouTube. I have one myself and there's literally millions of them out there. So what we're going to do is we're going to read in someone's name and print it back out here. There's a billion different ways to do this. I'm just going to make it as simple as possible. I'm going to say string name. So we're just simply making a C++ string, unknown type. What are you talking about here? Unknown type. Why? Why are you doing this? I know why. Because we are not using the namespace std. That's why. Now magically it works. That's one of the caveats from C++ and you can actually kind of go back and then do it this way if you really wanted to. Which way is right? It doesn't really matter. But point being once you start going into the standard library, you have to kind of adopt your way of doing it or you're going to have all these weird little errors. So we're just going to make a string and then I'm going to say, and I'm going to do it this way just so I can really differentiate what's part of the standard library and what's part of Qt. So it just really stands out on the screen. So I'm going to say C out, which of course is the C++ way of doing standard output. And I'm going to say, please enter your full name. Actually just please enter your name. I don't really care what your full name is, just enter a name. Now from here, I'm going to say standard library. Let's go ahead and get the line. And we're going to use the standard, the in. So we're just going to read the standard C in from the user. And read that into the string. Really no magic here. It just looks kind of verbose and ugly. I'm going to say STD, C out, hello, and then whatever your name is. All right, so from here, we have some issues. You see how reference to overloaded function could not be resolved. What are we talking about here? Well, let's see. Did I mean to call it? Probably because I didn't count, it's just C out. There we go. One of the issues there is just my horrible spelling. But if you get unresolved, really what that means is they are not sure what you're asking it to do. Now let's go ahead and replace this. And let's just see this work. Again, this is just the standard C++ way of doing things. Hello, Brian. Now you notice we got this little space that's not there either. Frustrating, we got to go in and change that. So one of the major takeaways here is when you do it the C++ way, there's all these minor little details you've got to start keeping up on and things don't always work the way you expect them to. And then you notice this right here. We're just adding a line return at the very end of it. Let's run it just to prove that we can do it. Hello, Brian. There we go. All right. Standard C++ as good as it is, gets a little chatting, a little verbose. I think there's probably a better way. Now that we've done it the C++ way, let's do it the cute way. And it's a little bit different, but it's also a little bit easier, I think. So I'm going to say void, do cute. Now, I'm not necessarily saying that the cute way is better. I'm just going to say that cute has a way of working with cute way easier than the standard library does, because of course, standard library doesn't know what cute is. So I'm going to go up here and I'm going to include cute text stream. The name is, well, fairly obvious. What it's going to do is a text stream. But you notice it starts with the letter Q. Anything that starts with letter Q, again, is baked right into cute. If you ever have some sort of curiosity as to what something is, you just simply highlight it and press F1 on the keyboard. And it brings up the built in help system. A lot of people don't even know that it's there. It's amazing. And it's right here as well. But anyways, it takes you right to whatever you've got highlighted. And it says the cute extreme class provides a convenient interface for reading and writing text, and they almost always give you built in code examples. So you can very rapidly, without even hitting Google, see exactly what's going on. This is extremely cool. And right here where my mouse is shows you almost exactly what we're going to do. Cute extreme stream, standard input. And there you go. I'm going to close that and let's go down here. Let's say Q text stream. And I say Q in, we're going to do the standard input. And then let's do a Q text stream. All this Q out. So really, all we're doing is we're telling cute to use a Q text stream and wrap the input and wrap the output. So we are using C++ in the background. Very simple, very easy. Now I'm going to say out and there's a bunch of different ways to work with this. But I'm going to just keep it ridiculously simple and do something like this, just the old copy and paste, please enter your name. And then from there, there's again, different ways we can do it. But I'm going to keep it as simple as possible. I'm going to say Q in dot read line. You know, I have read, read all read line. There's a lot of functionality baked into this. So there's a read line going to return a Q string. Now, just kind of ignore that first letter. It just means it's built to cute. So we're going to be reading a string, but it's cute's version of a string. We can put a max length if we want to. I don't really want to. And we just say something like this. You string name equal Q in read line. So we're just reading the standard input, converting it to a Q string. Very, very cool the way that works. And then we can, of course, just say Q out. And just output it. And we're going to output the name takes care of everything for us. It's nice and simple. So I'm going to grab this, comment this out, save, run. And notice nothing happens. Oh, no, what did we do? You out into your name. Why is this not working all of a sudden? Let's find out. So if we go to Q out and we hit this. There's no like anything that's really jumping out here. There's no like right or right line or anything like that. So it gets a little kind of scary. You may be going, did we break it? Unfortunately, you're going to have to do something like this. Q out that flush. Now let's go ahead and flush that again. Reason why you have to flush is you have to tell the operating system, hey, we are done writing to that stream and you can now push it out. So we're basically building a buffer that we can work with. And then when we're done with it, we flush that. It will pump it out to, you guessed it, standard output. So now I've got enter your name, I'm going to say Brian. Hello, Brian. Again, we've got this annoying little need of space here, not a big deal. We can literally just grab the same code and push it out. Let's rerun that again with do cute. Hello, Brian. See, it's actually pretty straightforward and pretty easy. And it really builds upon what you already know. So if you're familiar with C++, it's eerily familiar in cute. So far, we've demonstrated you can do things the standard C++ way or the cute way. But because cute is built on C++, you can actually mix and match these. And it gets kind of nuts. But let's go ahead and demonstrate this. I'm also going to introduce something that we're going to use fairly regularly here. So I'm going to say include cute debug. Now you actually don't need to include this because it's built right into Q core application. But again, I want you to just understand what we're doing. So the Q debug class provides an output stream, basically what we've done or debugging information. And this is actually extremely cool. Now you can output debug information. When I say debug information, we're not talking about hardcore C++ debug symbols. We're talking about levels of a logging. We can say a warning, critical, info, fatal, all these really cool things that we're going to cover in future videos. But just know that we can do this through basically what we've just done and we can mix and match this with C++. This is really cool. I love this. So I'm going to say void. You mixed. And this is the style I tend to favor. Again, just do what works for you. Now I'm going to beg and borrow pieces of this. I'm going to say I want our standard input using the QTECH stream. And now I want to say Q info. And this is just going to spit out some information on the screen. And notice it's got many, many overloads here. I must say these enter your name. Very cool the way that works. And then I can just say, hey, you know what, I want to read that line must click something on the keyboard, get that little pop up there. And then we can do this. Notice I'm going to get rid of that guy and I'm going to get rid of that guy. Simply don't need it anymore. Let's grab the mixed and let's go here. Save, run. And it works. Now, there's some fundamental things you need to be aware of, especially when using mixed here. So we are reading the standard input and Q info is doing something magical. Now, you're maybe going, why even mess around with Q debug, Q info and all that? Isn't it just under the hood using the standard output? Well, yes, it is, of course, but it does something magical. See how it's got it in quotes here. So it's actually smart enough to know that this is a string. It puts it in quotes and puts a little space there for us. This is something we're going to use over and over again. You'll see me use Q debug and Q warning and Q info and all that fun stuff just so we can get a peek at what's actually under the hood and what that data type actually is. There is also ways of tying this directly into logging systems. So anywhere in your application, if you use a Q debug or Q info or so on, you can pump that out to a file or the system log. It's incredibly powerful. I hope you enjoyed this video. You can find the source code out on github.com. If you need additional help, myself and thousands of other developers are hanging out in the Voidrealms Facebook group. This is a large group with lots of developers and we talk about everything technology related, not just the technology that you just watched. And if you want official training, I do develop courses out on you to me. This is official classroom style training. If you go out there and the course you're looking for is just simply not there, drop me a note. I'm either working on it or I will actually develop it. I will put a link down below for all three of those. And as always, help me help you smash that like and subscribe button. The more popular these videos become, the more I'll create and publish out on YouTube. Thank you for watching.