How to redefine Z-Order in Qt Widget

c++, qt, user-interface

Solution

If you want the ComposeMessageUi to block the mainwindow set the modal flag with

void setModal(true);

If your code is not derived from QDialog you eventually need to use

void setWindowModality(Qt::ApplicationModal);

(see documentation for alternative modality modes)

To just bring your window to the front you can use:

void QWidget::raise();

Problem

I have two Widget having separate implementation. They are ... MessageInboxUi ComposeMessageUi Both will show in fullscreen. In mainwindow I add both widget in following sequence ``` ComposeMessageUi* ptrEditor = new ComposeMessageUi(this); // these are inside MessageInboxUi * ptrInbox = new MessageInboxUi(this); // MainWindow Constructor ``` so when I call show function of ComposeMessageUi while MessageInboxUi is displaying, it does no display (because it displaying behind MessageInboxUi). How can I make ComposeMessageUi to front (I mean, how can I redefined their z-order)

Original source