Chinaunix首页 | 论坛 | 博客
  • 博客访问: 126889
  • 博文数量: 27
  • 博客积分: 1400
  • 博客等级: 上尉
  • 技术积分: 311
  • 用 户 组: 普通用户
  • 注册时间: 2008-01-28 09:05
文章分类

全部博文(27)

文章存档

2011年(1)

2010年(4)

2009年(4)

2008年(18)

我的朋友

分类:

2008-08-07 11:46:45

 #include <QApplication>
 #include <QPushButton>
 int main(int argc, char *argv[])
  {
     QApplication app(argc, argv);
     QPushButton *button = new QPushButton("Quit");
     QObject::connect(button, SIGNAL(clicked()),
                      &app, SLOT(quit()));
     button->show();
     return app.exec();
 }


Qt's widgets emit signals to indicate that a user action or a change of state has occurred. For instance, QPushButton emits a clicked() signal when the user clicks the button. A signal can be connected to a function (called a slot in that context), so that when the signal is emitted, the slot is automatically executed. In our example, we connect the button's clicked() signal to the QApplication object's quit() slot. The SIGNAL() and SLOT() macros are part of the syntax; they are explained in more detail in the next chapter.

阅读(1074) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~