 Hey everybody, this is Brian and welcome to the 23rd Qt Tutorial with C++ and GUI program. We're going to kind of backtrack a little bit here and I want to revisit the QMain window and show you something called Actions. So go File, New Project, Qt GUI Application and we'll say My Actions and wherever you've been putting these and make sure QMain window is selected. And once we have this up and going here, you notice how it says Type here? That's a menu. And then you get this thing right here, that's a toolbar. Over here are Actions, see how it says Action Editor. So actually type the word File, hit Enter and then you get these submenus. So we're going to say New, Open, Save. Now you notice how as I'm adding these in here, these actions are being popular, Action New, Action Open, Action Saved. So what are our actions? Well, instead of manually adding an item into the menu and then manually adding another item into the toolbar or onto the form, etc., etc., like you do in other languages, Qt has the concept of actions. And what an action is, is it allows you to have this class that interacts with the toolbar and the menu bars. So when you double click one of these, you see you can set the text, the object name, the tool tip, the icon, and whether or not it's checkable and the shortcut. And you can browse for icons through the resources. Let's cancel this. Let's go in here. And let's add a new, and we will say, Qt Resource File, just call it My Res, Finish. And if you remember from our previous tutorial, you have to add a prefix. So we'll call this Images. And you can add as many prefixes as you want, but we're just going to keep this simple and leave it as images. And then you can add files. And when you do this, it pops open a file dialog and you can add files. So let me pause this real quick because I admittedly I haven't had time to go hunt down some images. So I'm going to go grab a bunch of images and I'll be right back. All right. I got some files. Let me go add. And let me add in page white and add another file. Let me add in disk and add another file, add in folder. So there are my icons. I just got PNG files, but you can add literally any type of file. One thing you should note if you're adding in an image file is it should be an image file. It kind of goes without saying, but once in a while I get the bizarre email of how come my text file can't be an icon and I just kind of sit at my desk and wonder. All right. So actually let's close that Resource File. That way it saves it. Open this up and let's go Action New. And suddenly, magically, you have your images prefix and your image icons. And let's just set the icon for each one of these. Now in a real production application, you'd obviously have graphic designers or you'd go up to the internet and get some. And you'd name them appropriately, et cetera, et cetera. But I just, I have eight minutes left. So we're just going to very simply do this. Now you notice how suddenly they have icons. Very simple to work with. One thing you can do is you can take your actions and drag and drop them right onto the toolbar. Let's just save and run this. And there's our window with our icons. And notice the tooltips appear automatically. And there's our icons again. So what are actions? We understand that you can add them to a form. So let's just say, let's go Action Open. Go to Slot and we want Triggered. Now you have all these others. Don't worry about those for now. Just do Triggered. And there's our code. And in case you're wondering, and we should probably include a few things here before we start typing. Sorry about that. So now we got Qt Core and Qt GUI. So which means now we have access to the Q message box. Information. Oops. And so just very simply when we click this, it's going to pop open a message box. Compile and run. Now you notice how it says On Action Open Triggered. So when we've got our form, when we click Open, there's the dialog. And you can go into the menus and do the same thing. So you only have to write that code once. You don't have to write what I call plumbing code where you write, you know, when this menus click call this function and when this tool buttons click call this other function, you only have to write it once. And it's taken care of with actions. Very, very, very nice feature. Very easy to use. And I recommend you use it diligently because if you don't you're going to be paying the price. This is part of the Qt framework. And if you don't do it, darn it, Nokia and Qt, they are going to come punish you. But that and that show actions. Very simple. Very easy to work with. Just make sure you have your icons in the resource file. If you go to select your icons and they're not there, make sure you've saved your resource file. I went into the resource and closed it. That way it saved it. All right. This is Brian. Thank you for watching. I hope you found this video educational and entertaining.