当前位置:网站首页>QT Road (2) -- HelloWorld

QT Road (2) -- HelloWorld

2022-06-11 05:06:00 Skill code brother

Hello World

#include <QApplication>
#include <QWidget>
int main(int argc, char *argv[])
{
    
	QApplication a(argc, argv);
	QWidget w;
	w.show();
	return a.exec();
}

 Insert picture description here

  • Qt The header file doesn't have .h suffix ;
  • Qt A class corresponds to a header file , The class name is the header file name ;
  • QApplication Application class :
    • Manage control flow and main settings for GUI applications .
    • yes Qt The lifeblood of the whole backstage management she includes Main event loop , In which... From window systems and other resources All event handling and scheduling . It also handles Initialization and end of application , also Provide dialog management .
    • For any use Qt The GUI application for , There just happens to be one QApplication object , Whether or not the application has 0、1、2 Or more windows .
  • a.exec()
    The program enters the message loop , Waiting for the corresponding user input . here main() Transfer control to Qt,Qt Complete the event handling work , When the application exits exec() Will return . stay exec() in ,Qt Accept and process user and system events and pass them to the appropriate widgets .
原网站

版权声明
本文为[Skill code brother]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/03/202203020543216832.html