官术网_书友最值得收藏!

The Exit action

Take Exit action as an example. If users click it from the File menu, a signal named triggered will be emitted. So, let's connect this signal to a slot of our application instance in the MainWindow class's member function, createActions:

     connect(exitAction, SIGNAL(triggered(bool)), QApplication::instance(), SLOT(quit()));

The connect method takes four parameters: the signal sender, the signal, the receiver, and the slot. Once the connection is made, the slot on the receiver will be called as soon as the signal of the sender is emitted. Here, we connect the triggered signal of the Exit action with the quit slot of the application instance to enable the application to exit when we click on the Exit action.

Now, to compile and run, click the Exit item from the File menu. The application will exit as we expect if everything goes well.

主站蜘蛛池模板: 瑞昌市| 富蕴县| 洛南县| 马公市| 南乐县| 新余市| 醴陵市| 石棉县| 沽源县| 天台县| 上饶市| 社会| 北宁市| 万安县| 锦屏县| 女性| 太仆寺旗| 凤冈县| 沁源县| 溧水县| 卓尼县| 高雄县| 阿瓦提县| 牙克石市| 南皮县| 东丽区| 秦皇岛市| 克山县| 盖州市| 琼中| 和田县| 蒲江县| 如东县| 阿克苏市| 普格县| 融水| 金门县| 长阳| 漯河市| 密云县| 文昌市|