当前位置:网站首页>QT -- create QT program

QT -- create QT program

2022-07-08 01:57:00 bin elf

New folder -- Chinese path is not required

open qt 

  Example : It's a self-contained example

 


  Start to practice -- Create a new one qt

  Click on choose

  You can choose multiple or single -- next step

  Base class :QMainwindow  stay pc End windows window , With menu bar

Qdialog: Dialog box

qwidget: The most commonly used base class

Change to : amount to Class name is a subclass Base class : Parent class

That is : class myWidget:public QWidget

Click next complete  


  Realization effect :


Three ways to run  

 

  Shortcut key ctrl+r


function : Realization effect

  How to look at the code

 

  A program from main The function starts to see :

 

#include "mywidget.h"
#include <QApplication>
//QApplication Application class 
//Qt The header file doesn't have .h
// The header file is the same as the class name 
// The header file is capitalized with the first two letters 

int main(int argc, char *argv[])
{
    // Objects with and only one application class --- Even if there are many windows 
    QApplication a(argc, argv);
    //myWidget  Inherited from QWidget,QWidget Is a window base class 
    // therefore myWidget It is also a window class 
    //w It's just a window   Instance object 
    myWidget w;
    // Window creation is hidden by default , It needs to be displayed manually 
    w.show();
    // These two sentences are equivalent to the following sentence 
    //a.exec(); a Is the application window created earlier   Keep the program running , Waiting for user operation , Cycle all the time  
    // And wait for the event to happen ( Mouse events   The occurrence of keyboard events )
    //return 0;
    return a.exec();
}

Constructors Destructor  


  Go to the project file to check :

 

stay explorer It shows that

  after

 

 

 

The meaning of the module : Go to .h In file , Place the cursor in the base class Press F1 Enter the help document  

 

 

原网站

版权声明
本文为[bin elf]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/189/202207072328328164.html