Results 1 to 5 of 5

Thread: Preoblem with setQuitOnLastWindowClosed (false); and QMainWindow

  1. #1
    Join Date
    Feb 2008
    Posts
    16
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Preoblem with setQuitOnLastWindowClosed (false); and QMainWindow

    Hi for all.
    Now I develop sytem "Task Manager system " based on website + xmlrpc + windows software.

    ------------------------------------
    Some months ago I develop simple software:
    Qt Code:
    1. QApplication a(argc, argv);
    2. a.setQuitOnLastWindowClosed ( false);
    To copy to clipboard, switch view to plain text mode 

    Main window based on QWidget

    But now I use QMainWindow.

    Qt Code:
    1. QApplication a(argc, argv);
    2. a.setQuitOnLastWindowClosed (false);
    3. mainWindow = new Gefest(config);
    4. mainWindow->show();
    To copy to clipboard, switch view to plain text mode 

    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?
    Last edited by jpn; 11th May 2008 at 20:40. Reason: missing [code] tags

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Preoblem with setQuitOnLastWindowClosed (false); and QMainWindow

    It works fine for me. You must be doing something wrong. Maybe the application crashes and not closes itself gracefully?

  3. #3
    Join Date
    Feb 2008
    Posts
    16
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Preoblem with setQuitOnLastWindowClosed (false); and QMainWindow

    Qt Code:
    1. #include "gefest.h"
    2. #include "global.h"
    3. #include <QtGui>
    4. #include <QApplication>
    5. #include "class/Config.h"
    6.  
    7. #include <QStatusBar>
    8. #include <QUrl.h>
    9. #include <QtPlugin>
    10. #include <QDir>
    11. #include <curl/curl.h>
    12. #include <QMap>
    13.  
    14. #include "class/Screen.h"
    15. #include "class/UploadLogs.h"
    16. #include "class/TaskForm.h"
    17.  
    18. //Q_IMPORT_PLUGIN(qjpeg)
    19. //Q_IMPORT_PLUGIN(qgif)
    20.  
    21.  
    22. int main(int argc, char *argv[])
    23. {
    24. QApplication a(argc, argv);
    25. // a.disableSessionManagement();
    26. a.setQuitOnLastWindowClosed (false);
    27.  
    28. a.setApplicationName("Gefest");
    29. a.setApplicationVersion("1.0");
    30.  
    31.  
    32.  
    33.  
    34. tryIcon.addFile("img/gefest.png");
    35. trayIcon = new QSystemTrayIcon(tryIcon,&a);
    36. trayIcon->setVisible(true);
    37. trayIcon->show();
    38.  
    39.  
    40.  
    41. userLogId = "0";
    42.  
    43. appDir = QDir::currentPath();
    44. logDir = appDir + "/logs/";
    45. QDir * dir = new QDir(logDir);
    46. if(!dir->exists())
    47. dir->mkpath(logDir);
    48.  
    49. config = new Config("config/config.xml");
    50.  
    51.  
    52. UploadLogs ulogs;
    53. ulogs.init();
    54. // ulogs.uploadFile(logDir + "0__2008-05-06_23.49.52.png");
    55.  
    56.  
    57. server = QUrl(config->getValue("server")+config->getValue("xmlrpc"));
    58.  
    59. Screen screen;
    60.  
    61. statusbar = new StatusBar();
    62.  
    63. //########### INIT GLOBAL
    64. //user = new User(config);
    65. //task = new Task(config);
    66. user.init(config);
    67. mainWindow = new Gefest(config);
    68. mainWindow->show();
    69. a.setActiveWindow(mainWindow);
    70. task.init(config);
    71.  
    72.  
    73.  
    74.  
    75. // QObject::connect(mainWindow, SIGNAL(changeTaskType(QString&) ), &task, SLOT(changeTaskType(QString&) ));
    76.  
    77. //########## INIT GLOBAL
    78.  
    79. a.connect(&a, SIGNAL(lastWindowClosed()), &a, SLOT(quit()));
    80. return a.exec();
    81. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by jpn; 11th May 2008 at 20:40. Reason: missing [code] tags

  4. #4
    Join Date
    Feb 2008
    Posts
    16
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Preoblem with setQuitOnLastWindowClosed (false); and QMainWindow

    But in previous project work fine too.
    But I not use QMainWindow
    possible problem there.

  5. #5
    Join Date
    Feb 2008
    Posts
    16
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Preoblem with setQuitOnLastWindowClosed (false); and QMainWindow

    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();

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.