Thursday, July 2, 2009

GUI Hello World: Create GUI using Qt Designer

Now, I will create a GUI using Qt Designer.

To involve Qt Designer, right click mainwindow.ui, select Open With > and click Qt Designer.


Drag a Label from the Widget Box on the left side bar to the MainWindow.

And change the text to "who are you?", and change ObjectName field on the right side bar to label_WhoAreYou.

Drag a Line Edit to MainWindow, and change ObjectName to lineEdit_Name.

Drag a Push Button in MainWindow, change the text to OK, ObjectName to okButton.
Drag a Label to MainWindows, change the text to "I'm Qt", Object Name to label_Hello, and also change the alignment->Horizontal property to AlignHCenter.

Select the label_WhoAreYou and Line Edit, and click the Lay Out Horizontally button on the top tool bar.

Select all widgets, and click the Lay Out Vertically button on the top tool bar.

Finally, adjust the size of the window as you want, save and close Qt Design.

Now you can re-build in Qt Creator, the output window will be like it:



prev. -> GUI Hello World: Creat a dummy GUI Qt Application using Qt Ceator 1.2.0
next -> GUI Hello World: Add the code