qt - How to open QDialog window instead of CloseWindow in taskbar -


how can open qdialog window instead quitprogram in taskbar, when click right-button in closewindow?

check image

obs: have qdialog ui button quit program.

override qwidget::closeevent() function in main window. getting called when user tries quit application. example:

void yourmainwindow::closeevent(qcloseevent* ev) {     qmessagebox msgbox(qmessagebox::question,                        tr("quit"), tr("are sure want quit?"),                        qmessagebox::yes | qmessagebox::cancel);     msgbox.setdefaultbutton(qmessagebox::cancel); #ifdef q_os_mac     // presents dialog sheet in mac os.     msgbox.setwindowmodality(qt::windowmodal); #endif     if (msgbox.exec() == qmessagebox::yes) {         ev->accept();     } else {         ev->ignore();     } } 

Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -