c++ GUI programming with QT4

QT是一个跨平台的C++框架,用于使用一次编写、到处编译的方法开发GUI应用。本文介绍了QApplication和QLabel的用法,QApplication负责管理GUI应用的控制流程和主要设置,而QLabel则提供文本或图像显示功能。通过QApplication的event loop,程序等待用户操作并响应。QLabel可以设置为其他交互控件的标签,并支持快捷键设置。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

 

     Qt is a comprehensive(综合) c++ framework for devleoping cross-platform GUI applications using a "write once,compile anywhere" approach. Qt lets programmers use a single source tree for applicaion

 

    Hello Qt :

 

 

1.   QApplication :[QtGui module] : this class manage the GUI application' control flow and main settrings. contains the main event loop,where all events form the window system and other sources are processed and dispatched(委派). it also handles the application's initialization,finalization,and provids session management; In addition, QApplication handles most of the system-wide and application-wide settings.

For any GUI application using Qt, there is precisely one QApplication object, no matter whether the application has 0, 1, 2 or more windows at any given time. For non-GUI Qt applications, use QCoreApplication instead, as it does not depend on the QtGui library.

The QApplication object is accessible through the instance() function that returns a pointer equivalent to the global qApp pointer

 

  

 

2 QLabel[QtGui module] The QLabel widget provides a text or image display.A QLabel is often used as a label for an interactive widget. For this use QLabel provides a useful mechanism for adding an mnemonic (see QKeySequence) that will set the keyboard focus to the other widget (called the QLabel's "buddy").

3 Qt is so flexible(灵活) that any widget can be a window. this label is application window; 

4 app.exec(), the programe enters the event loop.this is kind of stand-by(备用) mode where the program waits for user action such as mouse clicks and key presses.

 

we don't bother calling delete on the QLabel object and the end .this memory will be reclaimed(回收) where the programe terminateds;

 

MAKING CONNECTIONS

 

 

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值