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
Post a Comment