Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. "undoing" setWindowFlags
Forum Updated to NodeBB v4.3 + New Features

"undoing" setWindowFlags

Scheduled Pinned Locked Moved General and Desktop
3 Posts 3 Posters 1.2k Views 3 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • canellasC Offline
    canellasC Offline
    canellas
    wrote on last edited by canellas
    #1

    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!

    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #2

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

      1 Reply Last reply
      0
      • kshegunovK Offline
        kshegunovK Offline
        kshegunov
        Moderators
        wrote on last edited by
        #3

        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
        }
        

        Read and abide by the Qt Code of Conduct

        1 Reply Last reply
        2

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved