Wednesday, July 7, 2010

A simple PushButton to quit, built as a Qt Gui Application

It have almost the same function of "A simple PushButton to quit" (start from empty Qt project), built as a Qt Gui Aplication, using Qt Designer.

- In Qt Creator, NEW a project by clicking on the File from the menu, then select New File or Project...
- Select Qt C++ Project in Projects on the left, and Qt Gui Application on the right, click Choose.


- Enter name and location of the project, then click Next, Next, Next and Finish.





Qt Creator will open the GUI in Design mode.

Place UI element
- Drag a Push Button on the main window, double click to edit the text, "Quit".


Specify Signal and Slot
- Click on the Edit Signals/Slots icon or press F4 to switch to Edit Signals/Slots mode.


- Pull a connection from the Push Button onto the background.


- A Configure Connection dialog will be opened. Click to show signals and slots inherited from QWidget. Select clicked() signal from pushButton, and close() slot from MainWindow, then click OK.


Now you can save, build and run your application.