连接信号和响应函数-data fusion- concepts and ideas

时间:2021-06-07 22:16:17
【文件属性】:
文件名称:连接信号和响应函数-data fusion- concepts and ideas
文件大小:2.44MB
文件格式:PDF
更新时间:2021-06-07 22:16:17
C++ GUI Programming with Qt 1.2 连接信号和响应函数 连接信号和响应函数 这个例子用来说明怎么响应信号,和 hello 程序的源代码相似,原来的 Label 用一个按钮代 替,点击时退出程序。 源程序如下: 1 #include 2 #include 3 int main(int argc, char *argv[]) 4 { 5 QApplication app(argc, argv); 6 QPushButton *button = new QPushButton("Quit"); 7 QObject::connect(button, SIGNAL(clicked()), 8 &app, SLOT(quit())); 9 button->show(); 10 return app.exec(); 11 } 当有所动作或者状态改变,qt 的控件会发出消息(signal),例如,当点击按钮时, 按钮会发送 clicked()消息,这个消息可以连接到一个函数上(这个函数在这里成为 slot)。

网友评论