 Hey everybody, this is Brian and welcome to the 15th Qt tutorial on C++ and GUI programming and today We're going to cover the Q push button All right now We're reutilizing our project from the last tutorial the GUI program and the only modification I've made is in the dialogue that CPP. I've added a reference to Qt core and Qt GUI And we're including those just to make it a little easier. So we don't have to include them every single time Now let's flip into our dialogue here And we're just going to add a Q push button You've probably seen push buttons a million times in your career and you know exactly what they do you click it and something happens well Qt you can add the text an icon you can make it checkable Whole slew of other properties. You should really explore the API because we're just going to cover the basics here One thing you should note is that you cannot do HTML formatting in the button It's just the way the API is So you can set the text here or you can double-click the button and just type it here We'll just say click me And let's save and run it Now when you run this you'll get your dialogue with a button on it and when you click it tada nothing happens Why is that well if you go back to our fourth tutorial on Qt programming signals and slots you know that when a Object emits a signal you need a slot to consume that or listen to it. Well, we haven't added a slot here The signals being admitted, but we're not listening to it. So you got to right-click the button go to slot and You get a whole list of slots associated with this button and we're just going to focus on click But you should know that there's pressed release toggled etc. Etc. Pressed is when the mouse is down releases when the mouse is up Toggled as if the buttons checkable it tells you the state whether it's checked or unchecked Just go ahead and select clicked and hit okay and that adds the on push button clicked function Now this is where the real work comes in When we push that button The signal will be emitted and the slot Which actually has been added into dialogue dot age is right here Void on push button clicked will be called And I'm going to show you the Q message box class And it's got a static function called information and you just need to set the parent set the title We'll just say title here And set the text we'll say hello world Now don't get too engrossed in the Q message box class. We're going to cover it in later tutorials I just wanted to show you so that when you click the button, you know that something happens Let's run our program and there's our button and when we click it Ta-da, there is our message box So very simple. It's one of the simpler controls out there, but one of the most used you'll use buttons a lot in your programs So this is Brian. I hope you found this video educational and entertaining and thank you for watching