Hello Qt

#include<QApplication>
#include<QLabel>
Int main(int argc,char *argv[])
{
	QApplication app(argc,argv);
	QLabel *label=new QLabel(“Hello Qt!”);
	Label->show();
	Return app.exex();
}


The QApplication object is used to manage the Application-wide resources;

The QApplication constructor requires argc and argv because Qt supports a few command-line arguments of its own;

Most applications use a QMainWindow or QDialog as the application window,but Qt is so flexible that any widget can be a window;

Widgets are always created hidden,so that we can customize them before showing them,thereby avoiding flicker;

The “return”statement:passes the control of the application on to Qt。At this point,the program enter loop;

User actions generate message to which the program can respond,ususlly by executing one or more functions;

 

 

int QApplication::exec () [static]

Enters the main event loop and waits until exit() is called, then returns the value that was set to exit() (which is 0 if exit() is called viaquit()).

It is necessary to call this function to start event handling. The main event loop receives events from the window system and dispatches these to the application widgets.

Generally, no user interaction can take place before calling exec(). As a special case, modal widgets like QMessageBox can be used before calling exec(), because modal widgets call exec() to start a local event loop.

To make your application perform idle processing, i.e., executing a special function whenever there are no pending events, use aQTimer with 0 timeout. More advanced idle processing schemes can be achieved using processEvents().

We recommend that you connect clean-up code to theaboutToQuit() signal, instead of putting it in your application'smain() function. This is because, on some platforms the QApplication::exec() call may not return. For example, on the Windows platform, when the user logs off, the system terminates the process after Qt closes all top-level windows. Hence, there is no guarantee that the application will have time to exit its event loop and execute code at the end of the main() function, after the QApplication::exec() call.

 

 

 

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值