Results 1 to 6 of 6

Thread: QMainWindow created after qApp->exec() doesn't show up

  1. #1

    Default QMainWindow created after qApp->exec() doesn't show up

    Just working on my first Qt ( qt4.2.3 / WinXP /GPL ) application.
    I've a systray icon, with 'new' , which will bring a new top level window.

    The problem is, this new QMainWindow is not visible. However when i
    exit, i see a flickr , so the window was created ..
    If I call my create function before qApp->exec(), the windows are create fine.

    What additional step is needed to get newly create QMainWindow into the
    list of top level windows ?


    The relevant code snippets:
    ===============================
    class Top : public QMainWindow
    {
    Q_OBJECT
    public:
    Top() {
    QTextEdit * textEdit = new QTextEdit;
    setCentralWidget(textEdit);
    }
    };
    ================================
    public slots:
    void actionNew() {
    Top * t = new Top();
    //t->showFullScreen();
    t->activateWindow();
    t->raise();
    t->repaint();
    t->show();
    }
    ================================

    --Regards
    ---Vardhan

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: QMainWindow created after qApp->exec() doesn't show up

    What does main() look like?
    J-P Nurmi

  3. #3

    Default Re: QMainWindow created after qApp->exec() doesn't show up

    my main() is standard:

    ======
    int
    main(int Argc, char **Argv)
    {
    Q_INIT_RESOURCE(term);
    QApplication a (Argc,Argv);

    app.startup();
    app.actionNew();
    app.actionNew();


    return a.exec();
    }
    =============

    'app.startup() create system tray with menu item which calls 'actionNew().
    The two top level created before a.exec() are visible, where the one create from 'new' are not.


    newAction = new QAction(tr("&New"), this);
    connect(quitAction, SIGNAL(triggered()), this, SLOT(actionNew()));


    --Regards
    ---Vardhan

  4. #4
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: QMainWindow created after qApp->exec() doesn't show up

    Notice that you connect quitAction to SLOT(actionNew()).
    J-P Nurmi

  5. #5

    Default Re: QMainWindow created after qApp->exec() doesn't show up

    Oh thanx ,, cut-n-paste problem (-:


    --regards
    ----vardhan

  6. #6

    Default Re: QMainWindow created after qApp->exec() doesn't show up

    And the flashing of window at exit should have given a clue (-:

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.