(Using Visual studio 2017)
Now, I’m going to show you how to create a Qt project and than I will explain step by step :) The example that I will create below just for beginning.
Firstly, If you already installed Visual studio and Qt libraries then just follow me but if not you can go to follow on this link: https://medium.com/@paryleevatou/how-to-setting-qt-gui-using-c-with-visual-studio-2017-dbb50406f99
Let’s go!
# Step 1 : Go to file -> new -> Project ->QtGUIApplication->(Change the name of your project) and attention to your Project Location! -> OK ->Next->Next-> Finish.
(In this example I gonna to use Qwidget for class base but if you want to change I recommend you change to Qmainwindow class base)
#Step 2: The Example_1.h class show up but still have error cause you have to compile the Example_1.ui class first like : click right then select Compile or Ctrl+F7
Then you have to click right on Generated File in the Solution Explorer to add ui_Example_1.h file.
“Every steps you have to run your Program step by step cause it will easy to solve the error or you will know where the error”
#Step 3: This step you have to include <qlabel.h> for displaying the text showing in GUI.
- QLabel is used for displaying text or an image. No user interaction functionality is provided. The visual appearance of the label can be configured in various ways, and it can be used for specifying a focus mnemonic key for another widget.
Step 4 : Change from Example_1 w to Qlable label{“Hello world”}; and change w.show to label.show(); then click “Save” and Run your program or test your program in “Local windows Debugger” button like the picture below:
The Result will show:
That’s Done ! Congratulation if you can follow until this step :)
Thank you ! see you in Next blog, The next blog will be “ QPushButton and QListWidget ”
Reference :
- http://doc.qt.io/archives/qt-4.8/qlabel.html#details
- Lecture 9 from Iuliana Bocicor, Lect.PHD