View Full Version : QMdiSubWindow stays always on top

20th July 2010, 17:55
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:

// So you know the types...
class DocumentWindow : public QMainWindow {};
class ScriptEditWindow : public DocumentWindow {};
class UiDefinitionWindow : public DocumentWindow {};

void MainArea::show(...)
// There is no window for this item: Create one
add(new ScriptEditWindow(boost::shared_static_cast<Script>(item), nullptr));
else if(boost::shared_dynamic_cast<UiDefinition>(item))
add(new UiEditWindow(boost::shared_static_cast<UiDefinition>(item), nullptr));

void MainArea::add(DocumentWindow* window)
auto subWindow = m_area.addSubWindow(window);

verify(connect(window, SIGNAL(closed(DocumentWindow*)), SLOT(onSubWindowClosed(DocumentWindow*))));

emit windowAdded(window);

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):

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.