PDA

View Full Version : Preoblem with setQuitOnLastWindowClosed (false); and QMainWindow



ivi2501
11th May 2008, 19:33
Hi for all.
Now I develop sytem "Task Manager system " based on website + xmlrpc + windows software.

------------------------------------
Some months ago I develop simple software:

QApplication a(argc, argv);
a.setQuitOnLastWindowClosed ( false);

Main window based on QWidget

But now I use QMainWindow.


QApplication a(argc, argv);
a.setQuitOnLastWindowClosed (false);
mainWindow = new Gefest(config);
mainWindow->show();

When I click close on MainWindow window not closed but hide to systemtray.
When I close subwindow software closed.
Please help.
setQuitOnLastWindowClosed not work with QMainWindow?

wysota
11th May 2008, 19:59
It works fine for me. You must be doing something wrong. Maybe the application crashes and not closes itself gracefully?

ivi2501
11th May 2008, 20:23
#include "gefest.h"
#include "global.h"
#include <QtGui>
#include <QApplication>
#include "class/Config.h"

#include <QStatusBar>
#include <QUrl.h>
#include <QtPlugin>
#include <QDir>
#include <curl/curl.h>
#include <QMap>

#include "class/Screen.h"
#include "class/UploadLogs.h"
#include "class/TaskForm.h"

//Q_IMPORT_PLUGIN(qjpeg)
//Q_IMPORT_PLUGIN(qgif)


int main(int argc, char *argv[])
{
QApplication a(argc, argv);
// a.disableSessionManagement();
a.setQuitOnLastWindowClosed (false);

a.setApplicationName("Gefest");
a.setApplicationVersion("1.0");




tryIcon.addFile("img/gefest.png");
trayIcon = new QSystemTrayIcon(tryIcon,&a);
trayIcon->setVisible(true);
trayIcon->show();



userLogId = "0";

appDir = QDir::currentPath();
logDir = appDir + "/logs/";
QDir * dir = new QDir(logDir);
if(!dir->exists())
dir->mkpath(logDir);

config = new Config("config/config.xml");


UploadLogs ulogs;
ulogs.init();
// ulogs.uploadFile(logDir + "0__2008-05-06_23.49.52.png");


server = QUrl(config->getValue("server")+config->getValue("xmlrpc"));

Screen screen;

statusbar = new StatusBar();

//########### INIT GLOBAL
//user = new User(config);
//task = new Task(config);
user.init(config);
mainWindow = new Gefest(config);
mainWindow->show();
a.setActiveWindow(mainWindow);
task.init(config);




// QObject::connect(mainWindow, SIGNAL(changeTaskType(QString&) ), &task, SLOT(changeTaskType(QString&) ));

//########## INIT GLOBAL

a.connect(&a, SIGNAL(lastWindowClosed()), &a, SLOT(quit()));
return a.exec();
}

ivi2501
11th May 2008, 20:24
But in previous project work fine too.
But I not use QMainWindow
possible problem there.

ivi2501
11th May 2008, 21:36
Sorry I find problem:)
I lost almost full day because not comment this line :(
#
a.connect(&a, SIGNAL(lastWindowClosed()), &a, SLOT(quit()));
#
return a.exec();