PDA

View Full Version : Non-modal dialog forces app to exit.



vereteran
17th October 2009, 07:42
Hi.

The story: my app got tray icon with menu attached, there's a point in menu called Configure that raises non-modal dialog. If i press Ok or Cancel in dialog application exits.
No error messages or at least info, it just exits.

The code:

Handler:


void AppMainWindow::config() {
if(!conf_dialog)
conf_dialog=new ConfigDlg(this);

conf_dialog->show();
conf_dialog->raise();
conf_dialog->activateWindow();
}

Action creation:



configAction=new QAction(tr("&Configure..."),this);
configAction->setStatusTip(tr("Displays configuration menu."));
connect(configAction,SIGNAL(triggered()),this,SLOT (config()));


Menu creation:


trayMenu=new QMenu(this);
trayMenu->addAction(showAction);
trayMenu->addAction(configAction);
trayMenu->addSeparator();
trayMenu->addAction(exitAction);


Tray icon creation:


tray=new QSystemTrayIcon(QIcon(":/icons/tray.png"),this);
tray->setContextMenu(trayMenu);
connect(tray,SIGNAL(activated(QSystemTrayIcon::Act ivationReason)),this,SLOT(trayActivated(QSystemTra yIcon::ActivationReason)));
tray->show();

vereteran
17th October 2009, 09:39
solution found:

setAttribute(Qt::WA_QuitOnClose, false);