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

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.

主站蜘蛛池模板: 秦安县| 大埔区| 托里县| 玉田县| 陈巴尔虎旗| 衡阳县| 磴口县| 刚察县| 专栏| 南汇区| 高台县| 长顺县| 柳林县| 山东| 德格县| 邹平县| 东乡县| 通榆县| 墨脱县| 邢台市| 江西省| 慈利县| 乌拉特后旗| 六枝特区| 武夷山市| 仲巴县| 南安市| 佛坪县| 鹤峰县| 津南区| 彰化县| 特克斯县| 洪泽县| 建昌县| 临海市| 化州市| 桐梓县| 邳州市| 吉林市| 米林县| 乌审旗|