"undoing" setWindowFlags
-
Hi,
I called
Qt::WindowFlags _flags = (Qt::Window |
Qt::CustomizeWindowHint |
Qt::WindowTitleHint
Qt::WindowStaysOnTopHint );
setWindowFlags (_flags & ~Qt::WindowSystemMenuHint);
on the constructor of a Window W1.When I create another Window W2, and define W1 as its parent, W2 seems to inherit W1 windows flags.
So, how do I make W2 use the default windows settings?
I tried
Qt::WindowFlags _flags = Qt::Window;
setWindowFlags (_flags & ~Qt::WindowStaysOnTopHint );
and some other combinations, but none worked.Thanks!
-
Hi
Not sure this is your case
On some platform / Oses (seen on ubuntu+unity)
the WindowStaysOnTopHint dont really come of again.
Also saw on linux Mint+xfce. Even if one take the flag off
the windows manager dont care and it remains on top.Code looks correct
Qt::WindowFlags flags = windowFlags();
if (ui->checkBoxKeepOnTop->isChecked())
flags |= Qt:: WindowStaysOnTopHint;
else
flags &= ~Qt:: WindowStaysOnTopHint;
setWindowFlags(flags); -
said in "undoing" setWindowFlags:
I called
[... snippet ...]
on the constructor of a Window W1.That's incorrect. Something like this, should behave better (assuming you derive from
QWidget
):MyWidget::MyWidget(QWidget * parent) : QWidget(parent) { setWindowFlags(flags() & ~Qt::WindowSystemMenuHint); // Don't overwrite flags set automatically by Qt }