求大神解释一下qt程序从编译到运行的过程,还有为什么一定要有QApplication a(argc,argv)对象。
qassistant中有对QApplication的详细说明。
对于QApplication它有如下说明:
It initializes the application with the user's desktop settings such as palette(), font() and doubleClickInterval(). It keeps track of these properties in case the user changes the desktop globally, for example through some kind of control panel.
It performs event handling, meaning that it receives events from the underlying window system and dispatches them to the relevant widgets. By using sendEvent() and postEvent() you can send your own events to widgets.
It parses common command line arguments and sets its internal state accordingly. See the constructor documentation below for more details.
It defines the application's look and feel, which is encapsulated in a QStyle object. This can be changed at runtime with setStyle().
It specifies how the application is to allocate colors. See setColorSpec() for details.
It provides localization of strings that are visible to the user via translate().
It provides some magical objects like the desktop() and the clipboard().
It knows about the application's windows. You can ask which widget is at a certain position using widgetAt(), get a list of topLevelWidgets() and closeAllWindows(), etc.
It manages the application's mouse cursor handling, see setOverrideCursor()
大意是它要负责初始化应用、处理窗口事件、分析命令行的参数、定义程序外观、字符串的本地化、提供了一些魔术对象、了解窗口的基本信息、管理程序的鼠标指针处理等。要具体弄清楚的话就读qassistant。
对于QApplication它有如下说明:
It initializes the application with the user's desktop settings such as palette(), font() and doubleClickInterval(). It keeps track of these properties in case the user changes the desktop globally, for example through some kind of control panel.
It performs event handling, meaning that it receives events from the underlying window system and dispatches them to the relevant widgets. By using sendEvent() and postEvent() you can send your own events to widgets.
It parses common command line arguments and sets its internal state accordingly. See the constructor documentation below for more details.
It defines the application's look and feel, which is encapsulated in a QStyle object. This can be changed at runtime with setStyle().
It specifies how the application is to allocate colors. See setColorSpec() for details.
It provides localization of strings that are visible to the user via translate().
It provides some magical objects like the desktop() and the clipboard().
It knows about the application's windows. You can ask which widget is at a certain position using widgetAt(), get a list of topLevelWidgets() and closeAllWindows(), etc.
It manages the application's mouse cursor handling, see setOverrideCursor()
大意是它要负责初始化应用、处理窗口事件、分析命令行的参数、定义程序外观、字符串的本地化、提供了一些魔术对象、了解窗口的基本信息、管理程序的鼠标指针处理等。要具体弄清楚的话就读qassistant。
温馨提示:答案为网友推荐,仅供参考
第1个回答 2015-05-20
你是怎么说的啊