c++ - QWidget doesn't close when main window is closed -


i'm trying make main window (qwidget) open new qwidget when button clicked when close main window, qwidget opened doesn't close.

main.cpp

qapplication a(argc, argv); mainwindow w; w.show(); return a.exec(); 

mainwindow.cpp (parent)

mainwindow::mainwindow(qwidget *parent) :     qmainwindow(parent), ui(new ui::mainwindow) {     ui->setupui(this); } 

out.cpp (child)

out::out(qwidget *parent) :     qwidget(parent),     ui(new ui::out) {     ui->setupui(this);  } 

i suspect you're looking qt::wa_quitonclose:

makes qt quit application when last widget attribute set has accepted closeevent(). behavior can modified qapplication::quitonlastwindowclosed property. default attribute set widgets of type qt::window.

in case, should call:

mywidget->setattribute( qt::wa_quitonclose, false ); 

Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -