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

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.

主站蜘蛛池模板: 文水县| 连城县| 达拉特旗| 加查县| 漳州市| 平阴县| 灵川县| 汨罗市| 胶南市| 金秀| 北海市| 湖北省| 宝坻区| 曲水县| 连云港市| 班戈县| 滨州市| 武胜县| 太原市| 溧水县| 景德镇市| 富平县| 新闻| 新昌县| 拉萨市| 忻城县| 河池市| 泰宁县| 长乐市| 灵石县| 沙坪坝区| 萍乡市| 读书| 达尔| 神木县| 武定县| 嘉祥县| 云安县| 寿宁县| 金乡县| 通辽市|