- Qt 5 and OpenCV 4 Computer Vision Projects
- Zhuo Qingliang
- 148字
- 2021-06-24 13:59:17
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.
- 案例式C語言程序設(shè)計(jì)
- Java系統(tǒng)分析與架構(gòu)設(shè)計(jì)
- SQL Server 2012數(shù)據(jù)庫技術(shù)及應(yīng)用(微課版·第5版)
- C語言程序設(shè)計(jì)實(shí)訓(xùn)教程
- NativeScript for Angular Mobile Development
- 編寫高質(zhì)量代碼:改善C程序代碼的125個(gè)建議
- SharePoint Development with the SharePoint Framework
- Java系統(tǒng)化項(xiàng)目開發(fā)教程
- SQL Server數(shù)據(jù)庫管理與開發(fā)兵書
- Creating Mobile Apps with jQuery Mobile(Second Edition)
- Python3.5從零開始學(xué)
- 智能搜索和推薦系統(tǒng):原理、算法與應(yīng)用
- Deep Learning with R Cookbook
- 深入解析Java編譯器:源碼剖析與實(shí)例詳解
- MySQL數(shù)據(jù)庫教程(視頻指導(dǎo)版)