Results 1 to 3 of 3

Thread: QMdiArea addSubWindow is not showing window when called from slot

  1. #1
    Join Date
    Apr 2010
    Posts
    5
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default QMdiArea addSubWindow is not showing window when called from slot

    I am passing a MdiArea into a QWidget *child:
    Qt Code:
    1. mdiArea = new QMdiArea;
    2. setCentralWidget(mdiArea);
    3.  
    4. tabWidget = new QTabWidget;
    5. QWidget *child = new parametertab(tabWidget, mdiArea);
    6.  
    7. mdiArea->addSubWindow(child); //this addSubWindow works as expected
    To copy to clipboard, switch view to plain text mode 

    Inside the parametertab constructor, I can addsubwindow, but it does not work when I addsubwindow from within a slot. It does add the window to the subWindowList, and does not produce a warning. Any idea why it does not display the window?
    Qt Code:
    1. class parametertab : public QWidget
    2. {
    3. ...
    4. private slots:
    5. void runsim();
    6. ...
    7. }
    8.  
    9. parametertab::parametertab(QTabWidget *tW, QMdiArea *ma, QWidget *parent)
    10. : QWidget(parent)
    11. {
    12. ...
    13. QWidget *child = new QTextEdit;
    14. mdiArea->addSubWindow(child); //this works as expected
    15. ...
    16. }
    17.  
    18. void parametertab::runsim()
    19. {
    20. QWidget *child = new QTextEdit;
    21. mdiArea->addSubWindow(child); //does not show window?
    22. }
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Apr 2010
    Posts
    5
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QMdiArea addSubWindow is not showing window when called from slot

    A little more info. The signal is from a push button:
    Qt Code:
    1. connect(buttonRun, SIGNAL(clicked()),
    2. this, SLOT(runsim()));
    To copy to clipboard, switch view to plain text mode 

  3. #3
    Join Date
    Apr 2010
    Posts
    5
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QMdiArea addSubWindow is not showing window when called from slot

    Now working. Had to add activateWindow() and raise() to get it to show.

    Qt Code:
    1. void parametertab::runsim()
    2. {
    3. QWidget *child = new QTextEdit;
    4. mdiArea->addSubWindow(child);
    5. child->activateWindow();
    6. child->raise();
    7. }
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. Replies: 2
    Last Post: 7th May 2010, 10:41
  2. Slot doesn't get called
    By waynew in forum Qt Programming
    Replies: 7
    Last Post: 18th April 2010, 13:34
  3. How come this slot doesn't get called every second?
    By ShaChris23 in forum Qt Programming
    Replies: 2
    Last Post: 5th November 2009, 23:41
  4. Slot gets called twice
    By greatgatsby in forum Newbie
    Replies: 7
    Last Post: 20th August 2009, 15:11
  5. SLOT not being called
    By steg90 in forum Qt Programming
    Replies: 4
    Last Post: 6th December 2007, 11:30

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.