Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Adding SubWindow to a MDI Area will not work inside a slot function
Forum Updated to NodeBB v4.3 + New Features

Adding SubWindow to a MDI Area will not work inside a slot function

Scheduled Pinned Locked Moved General and Desktop
2 Posts 1 Posters 3.9k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    billconan
    wrote on last edited by
    #1

    I am wondering if this is a known bug, or I simply missed something.

    What I want to do is simple: Adding a sub window to an MDI area.

    @mdiArea->addSubWindow(new QWidget());@

    this line of code works fine if it inside the constructor of my window class.

    But I want to add the subwindow by clicking a button.

    if the "adding sub window" code is inside the button's slot function, it will not work anymore. Nothing will appear within the mdi area.

    I am developing under Mac OS Lion with Qt4.8

    here is my code:

    @MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
    {
    ui->setupUi(this);

    addSubWindow= ui->mainToolBar->addAction("Add SubWindow");
    
    connect(addSubWindow,SIGNAL(triggered()),this,SLOT(onAddSubWindow()));
    
    //This line can add a sub window to the mdi area
    //ui->mdiArea->addSubWindow(new QWidget());
    

    }

    void MainWindow::onAddSubWindow()
    {
    //but if add a sub window from a slot function, it will not work. nothing will appear within the mdi area.
    ui->mdiArea->addSubWindow(new QWidget());
    }

    MainWindow::~MainWindow()
    {
    delete ui;
    }
    @

    here is my qt project that repros this issue :http://dl.dropbox.com/u/3315090/mdibug.zip

    1 Reply Last reply
    0
    • B Offline
      B Offline
      billconan
      wrote on last edited by
      #2

      This is not a bug, I figured out why after looking at the MDI example.

      I need to call SubWindow->show() after I add it to the mdi area.

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved