Re create an empty project , It's here :

Then create a new empty project step by step by default .

 

 

Step 2 , Add in project main.app file . Right click the project folder in the project file list to select c++ source file . The steps are as follows :

Step 3 start typing code .

The code is as follows :

#include<QDialog> #include<Qlabel.h> #include<QApplication> int main(int
argc,char **argv){ QApplication a(argc,argv); QDialog w; QLabel label(&w);
label.setText("hello,wolrd! Hello "); w.show(); return a.exec(); }
  Need attention : Because my version is QT5, Default above QApplication,QDialog
,Qlabel stay QtWidgets In the module , So if you run the above code directly, you will get an error .

resolvent :

stay .pro Add to file :
QT += core gui greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
 

This will solve the problem QT4,QT5 The first conflict of .

 

Summary process :

1.. Write source file

2.. modify .pro

3.. Compile run

 

Final results run :

The upper window is too small , Window size needs to be changed .

Code to set window size :

QDialog w;

w.resize(x,y);

 

Then in order to move the font to the specified location , It can be used

QLabel label(&w);

label.move(x,y);

Final display effect :

 

Technology
©2019-2020 Toolsou All rights reserved,
Bitcoin in ten years ,VDS Opportunity or fraud Don't annoy the panda with any cat !「 Kung Fu Panda 」20 It's the year of man 4 blood sort ( one ) bubble sort Random forest R Language implementation java Realize the function of grabbing red packets Python Basic knowledge and notes python To solve the problem of dictionary writing list in CSS architecture design Vue Common features ( one )2021 year 2 Monthly programmer salary statistics , average 15144 element