I've created an Application that contains a QMdiArea. I can add QMainWindows as subwindows to it, however I cannot change their z-order, by clicking on such a sub window, or by clicking on the appropriate tab.

It's quite alot of code, but this is the part, responsible for adding & creating a new QMainWindow:
Qt Code:
  1. // So you know the types...
  2. class DocumentWindow : public QMainWindow {};
  3. class ScriptEditWindow : public DocumentWindow {};
  4. class UiDefinitionWindow : public DocumentWindow {};
  5.  
  6. void MainArea::show(...)
  7. {
  8. // There is no window for this item: Create one
  9. if(boost::shared_dynamic_cast<Script>(item))
  10. add(new ScriptEditWindow(boost::shared_static_cast<Script>(item), nullptr));
  11. else if(boost::shared_dynamic_cast<UiDefinition>(item))
  12. add(new UiEditWindow(boost::shared_static_cast<UiDefinition>(item), nullptr));
  13. }
  14.  
  15. void MainArea::add(DocumentWindow* window)
  16. {
  17. window->changeState(m_state);
  18. auto subWindow = m_area.addSubWindow(window);
  19. subWindow->show();
  20.  
  21. verify(connect(window, SIGNAL(closed(DocumentWindow*)), SLOT(onSubWindowClosed(DocumentWindow*))));
  22.  
  23. emit windowAdded(window);
  24. }
To copy to clipboard, switch view to plain text mode 

Both DocumentWindow subclasses pass the parent, passed to the constructor down to DocumentWindow (which passes it to QMainWindow). Changing the parent to m_area (which is a QMdiArea) doesn't change the behaviour.

To demonstrate, here are 2 screenshots. I tried to activate a certain window by clicking the tab, but only the focus changes, the z-order stays the same (which is always the order I've added the windows to QMdiArea):
subwindow2..png
subwindow1..png

Running the Qt example works fine, so the problem must be a part of my code. However I have no idea what could be causing the observed behaviour.