I use a QMainWindow as child of my main QMainWindow. By that I get an other area which I can use for dockable widgets (QDockWidget).
According to the following posts this is OK, it also works perfectly for me.
To make the QMainWindow behaving as a normal widget, I unset the window flag, this trick is mentioned in one of the posts above.
Now I also want to be able to float this child QMainWindow with all its docked widgets. In other words, I want to revert the step "making it a normal widget". Unfortunately,  this does does not work. It is gone from the main window, but not visible at all.
Any way to resolve it?
// this is the child QMainWindow
if (this->m_infoAreaFloating)
{
    // this should give me a floating window besides the main window
    this->setWindowFlags(Qt::Desktop);
    this->show();
}
else
{
    // make this compliant as QWidget
    this->setWindowFlags(this->windowFlags() & ~Qt::Window);
}
Related: a , b
The Qt::Desktop flag is not something you are supposed to set by yourself.
You need to set the Qt::Window flag:
setWindowFlags(m_infoAreaFloating ? Qt::Window : Qt::Widget);
show();
There's no point to this->windowFlags() & ~Qt::Window: you've cleared all other window flags when setting the lone Qt::Window flag. You're in full control of the flags, there's no need to preserve some "other" flags: there are none.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With