 Hey everybody, this is Brian and welcome to the 89th Qt Tutorial and this is also, I believe, my 200th tutorial in total. So yeah, pause for celebration there. For this tutorial, we're not going to do anything too special unfortunately. I do want to kind of show you, I have upgraded to the newest version of Qt Creator 2.2.1, so you can expect that in the new tutorials. What we're going to do today is cover the standard dialog boxes. So on the welcome page, you can actually go to explore the Qt C++ examples and then go up to dialogs, I'm sorry it goes off my screen, and then go to standard dialogs. Just open that up and you may get some dialogs saying, hey, where do you want to put this, etc., etc. The help will pop open and it'll show you basically, you know, the source code and it kind of goes through and explains some of this stuff. But we're going to run this and actually go through this thing. So if you flip into the code, you'll see get these standard rules, these Symbian rules. Somebody asked me, what are all these things? Well, these are just in case you're going to build this for a phone and it adds for the Nokia Symbian rules. You're not building it for a phone, so you don't really need to worry about it. All right, now let's just go into main and you can see it's just a standard Q application, builds a string, builds a translator, and basically we'll get into translations in another tutorial, but one thing you should be aware of is that Qt is translation aware, meaning everything you display on the screen can be translated to another language and it's very simple and easy to do. And then it just does a dialog.exec, you know, pretty simple. You'll notice through the Qt tutorials though, they don't actually use the form resources. They do pretty much everything through code. And well, it's a matter of personal preference, which we like to do. I like having the form, some people like just doing it straight through code, but that's kind of, you know, an ode to Qt. It's very flexible, you can do it either way. So if you open dialog.exec, you can see there is just a massive amount of stuff in here. There's a bunch of signals and slots going on here and they got a bunch of pointers to stuff. And go ahead and close that and then just open dialog.cpp. We're just going to run this. Just for the sake of argument, let's just run this thing and see what it does. And the reason why I wanted to use a built-in Qt example rather than building one from scratch as well, it's already been done. So why reinvent the wheel? And they did a pretty good job. I mean, probably much better than I could have done to be brutally honest. All right. Now every button here, you see how it says Q something and then colon colon and then something. Well, it's Q input dialog and then get int. So you're basically saying Q input dialog called the get int function and you can get an integer. Now if you type in like a bunch of letters, nothing happens. If you type in like one point, blah, blah, blah, nothing happens. And that's because, well, it's expecting an integer and you notice it's got a built-in spin box. And it also shows you how to format and percents. Now let's actually close this and I want to go over some stuff in the editor. Something we really haven't covered before. The editor is actually very, very dynamic. You see if you hover your mouse over that little arrow, you can actually collapse segments of text. And it jumped us right to our set int. And you can see the Q input dialog get int. And there's the actual code that does this. We're saying the TR, that's the translate that I was talking about earlier. Anytime you put a string inside the TR macro or actually think it's a TR function, that means that's translatable. So don't get thrown by TR. All they're saying is this could be done in another language if we need to. And then they're displaying it as a percentage. And then they're just saying, you know, the label set text and they're just displaying it as a percentage. It's not really hard. Another thing you should be aware of are these drop-down dialog or drop-down boxes. You see how you can select a symbol and just jump instantly to it. So if you wanted to go to dialog set font, jump shutter down. Just a little thing. I don't know if we've ever covered that before. So I wanted to hit that really quick because somebody said, hey, where are you finding all these great hints for the editor? Admittedly, I'm finding most of these great hints from you guys. All right, let's go through these. Get int just returns an integer. Get double. Well, returns a double. Notice the period in there. And of course, they format it differently. Get item. That's where they actually send it a list of items. And you can choose from those items. And let's actually go to Q and put dialog. Get item. I want to explore that one a little bit. Set item. Here it is. And as you can see, we're just building a Q string list of items. And they're just putting in translatable strings. Spring, summer, fall, winter. And then they're just saying Q and put dialog. Get item. And then you pass it the list of items. And it's basically just returning the item that was selected. So there's really no voodoo magic. Once you go in here, these funky little comments actually go out to the help system. So if you're following along in their help, you can kind of figure out what they're talking about there. And let's continue exploring this example here. I mean, you have the code, so I'm not going to really go over too much of the code. I just want to go over the dialogs and show you what they do. Get dent. We've done that. Get double. We've done that. Get item. We've done that. Get text. This is like the standard input dialog you're used to if you've used a visual basic. Get color. Very easy. You can get a color. And notice how it returns both the hex value of the color. That may not come in too well in the video. Let me grab a different color there. The hex value plus it actually sets the background color. Get font, of course, is a standard font dialog. And it sets the font. Get existing directory. This will look different depending on which operating system you're in, but it allows you to basically choose a directory and nothing else. And get open file name. Allows you to say, okay, what file do you want to open? And then get open file names. Plural allows you to choose more than one. And if you do that, like if you choose multiple files, you know, so you got this little filter that you can set to, you can have a very, very big dialog so it'll just span it out. And get save name. And the unique thing about get save name is it'll actually check to see if the file would exist. So if you try to overwrite something, it's going to say, do you want to replace this? Now if you hit yes, you haven't actually done anything to replace. It's just warning the user, hey, this thing exists. And then you've got your message boxes, which you've seen in other applications here. And you can get the option the user selects. Let me actually move this window over here. Information. You've seen these before. Question, sorry about that. Yeah, just displays the question mark. Warning, displays a warning. And show message. And Unicode's got this little check box. Show this message again. If you leave that checked, you'll see it again and again. See? But if you uncheck it, you won't see that message ever again. And that's actually stored in the registry if you're in Windows or in an INI file, I believe, if you're in Linux or Mac. Now notice this little use native file dialog. Let's actually go to the open file. And Unicode's the nice native dialog. Now what does native mean? It means it's built into the operating system. Let's uncheck that. I want to show you what happens if you do this. Notice how it takes a little longer to open up and it looks different. It looks kind of foreign. I mean, it's still usable. But it looks different. And sometimes that'll throw your end users off. So a general rule of thumb is always use the native file dialogs. So lot in here. I definitely think you should explore all the examples that come with Qt Creator. This one in particular has helped me out many, many, many times. And use these dialogs whenever you can. I mean, there's no sense in reinventing these when they already exist. For example, if you need a color, it's very simple to just say Qt Color Dialog, Get Color. And then you've got the source code right here. So you can say, where is it? Set color. And then you've got all the source code that shows you exactly how to get this. Qt Color, Get Color. If Native, Check. Notice how they're saying if Native. Otherwise, and then they show you how to do the do not use native dialog. So it uses the built-in Qt Dialog. And then it shows you how they actually got the hex value and set the background color and all that. So that's really it for this tutorial. I just wanted to let you guys be aware that this code actually exists on your hard drive because I had quite a few requests for, hey, how do I open this? How do I do that? We've already got the code right in front of you. I know I'm still finding examples that I did not know existed. So anyways, I wanted to thank you guys for watching. This is my 200th video. So I'm going to throw a small celebration. I know it's been a while since I've made a video. I've been really busy with work and life and a couple other things. I've actually signed up for the Qt Ambassador program. And what this is, is if you're an individual out in the world and you display some sort of leadership and you're promoting Qt and you're working with it, you can sign up for this. And I've actually been in contact with a couple people. Her name's Alexandra, I believe. She's in the official Qt forums. I've spoken with her once. But they're incredibly busy ramping up for Qt days, developer days, sorry. So just if you're out there, just kind of, you know, put in a good word for me because I got my application and I'd really like to be a Qt ambassador. And as always, I'm going to throw these tutorials out into my website, voidrums.com. Just go under Qt and just search for the tutorial you're looking for. And I wanted to say thank you guys very much for your feedback and support. 200 video sounds like a lot, but actually it went pretty fast. I'm kind of surprised I have 200 videos. So thank you and keep up the feedback. I really want to get going on some more stuff with Qt and some more stuff with C-Sharp. And I'm kind of wondering if we should do some PowerShell and maybe some Python. But anyways, let me know what you guys think.