Objective: create a new project Hello World
Performance:
- Open QtCreator;
- Go to File -> New File or Project;
- Select the project type "Application" -> "Qt Widgets Application", press the Select button;
- Name your project (for example, Hello world) and select the folder in which the project will be created, click Next;
- Select the library bundle that fits your system (for example, Desktop Qt 5.3 MSVC2013 32bit), click Next;

- Enter the class name (the name of the main form file) or leave the field unchanged (the standard class name mainwindow will be used later), click Next;
- If you need version control and you have the appropriate utility installed, select it in the appropriate drop-down menu; click Finish;
- Double-click to open the form file (mainwindow.ui);
- Drag 2 Label objects (Display Widgets section) and 1 Push Button object (Buttons section) onto the form;

- Select 1st TextLabel, double-click on the object to change its inscription to "Hello World";
- In the properties of the object (lower right corner), QLabel section, change the textFormat property to RichText;
- Click on the text property, a button will appear to the right of the text (...), click on it;
- In the window that opens, select all the text, set its font size to 16, italics, click OK;

- In the left pane, open the Editor, double-click to open the header file (mainwindow.h);
- After the lines
private:
Ui :: MainWindow * ui;
add the following line:
private slots:
void helloWorld (); - Open the mainwindow.cpp file and add the following code:
1) after the line
ui-> setupUi (this);
add
connect (ui-> pushButton, SIGNAL (clicked ()), this, SLOT (helloWorld ()));
2) at the end of the file add the following code:
void MainWindow :: helloWorld () {
ui-> label_2-> setText ("World Hello");
} - Run the project (button in the lower left corner, or Ctrl + R combination).
Result:

Comments
To leave a comment
Cross platform programming
Terms: Cross platform programming