You get a bonus - 1 coin for daily activity. Now you have 1 coin

1. Practice Meet QT Creator.

Lecture



Objective: create a new project Hello World

Performance:

  1. Open QtCreator;
  2. Go to File -> New File or Project;
  3. Select the project type "Application" -> "Qt Widgets Application", press the Select button;
  4. Name your project (for example, Hello world) and select the folder in which the project will be created, click Next;
  5. Select the library bundle that fits your system (for example, Desktop Qt 5.3 MSVC2013 32bit), click Next;
      1. Practice Meet QT Creator.
  6. 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;
  7. If you need version control and you have the appropriate utility installed, select it in the appropriate drop-down menu; click Finish;
  8. Double-click to open the form file (mainwindow.ui);
  9. Drag 2 Label objects (Display Widgets section) and 1 Push Button object (Buttons section) onto the form;
      1. Practice Meet QT Creator.
  10. Select 1st TextLabel, double-click on the object to change its inscription to "Hello World";
  11. In the properties of the object (lower right corner), QLabel section, change the textFormat property to RichText;
  12. Click on the text property, a button will appear to the right of the text (...), click on it;
  13. In the window that opens, select all the text, set its font size to 16, italics, click OK;
      1. Practice Meet QT Creator.
  14. In the left pane, open the Editor, double-click to open the header file (mainwindow.h);
  15. After the lines
    private:
    Ui :: MainWindow * ui;
    add the following line:
    private slots:
    void helloWorld ();
  16. 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");
    }
  17. Run the project (button in the lower left corner, or Ctrl + R combination).

Result:

  1. Practice Meet QT Creator.


Comments


To leave a comment
If you have any suggestion, idea, thanks or comment, feel free to write. We really value feedback and are glad to hear your opinion.
To reply

Cross platform programming

Terms: Cross platform programming