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

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.

主站蜘蛛池模板: 南京市| 蒙城县| 道真| 翼城县| 泗阳县| 北安市| 乐亭县| 鄯善县| 蒙自县| 即墨市| 庐江县| 东海县| 大同市| 聂拉木县| 潮安县| 综艺| 新龙县| 江山市| 库车县| 广德县| 申扎县| 乌拉特后旗| 朝阳区| 汝南县| 治多县| 沛县| 监利县| 菏泽市| 噶尔县| 潞城市| 岑巩县| 阿坝| 阳曲县| 新邵县| 略阳县| 新闻| 来安县| 辉县市| 汕头市| 屏山县| 岳池县|