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. Always On Top Again
Qt 6.11 is out! See what's new in the release blog

Always On Top Again

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 3 Posters 747 Views 1 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.
  • Epiales666E Offline
    Epiales666E Offline
    Epiales666
    wrote on last edited by Epiales666
    #1

    I have searched here and all over the internet to try and find a solution to get the checkbox is checked state to allow the window to stay on top. I am not looking for a button to click, but just click the checkbox and it stays on top, or unchech it and it doesn't stay on top. This is what I have:

    void MainWindow::on_checkBox_stateChanged(int arg1)
    {
        Qt::WindowFlags flags = windowFlags();
        if (ui->checkBox->isChecked())
        flags |= Qt:: WindowStaysOnTopHint;
    }
    

    Any help would be appreciated, thank you!

    This is what I have in the header:

    private slots:
        void on_checkBox_stateChanged(int arg1);
    

    Be Blessed!
    Epiales666

    Kent-DorfmanK 1 Reply Last reply
    0
    • Epiales666E Epiales666

      I have searched here and all over the internet to try and find a solution to get the checkbox is checked state to allow the window to stay on top. I am not looking for a button to click, but just click the checkbox and it stays on top, or unchech it and it doesn't stay on top. This is what I have:

      void MainWindow::on_checkBox_stateChanged(int arg1)
      {
          Qt::WindowFlags flags = windowFlags();
          if (ui->checkBox->isChecked())
          flags |= Qt:: WindowStaysOnTopHint;
      }
      

      Any help would be appreciated, thank you!

      This is what I have in the header:

      private slots:
          void on_checkBox_stateChanged(int arg1);
      
      Kent-DorfmanK Offline
      Kent-DorfmanK Offline
      Kent-Dorfman
      wrote on last edited by
      #2

      @Epiales666 said in Always On Top Again:

      WindowStaysOnTopHint

      What's the last part of the word above? The window manager can override what you specify in Qt.

      The dystopian literature that served as a warning in my youth has become an instruction manual in my elder years.

      1 Reply Last reply
      2
      • J.HilkJ Offline
        J.HilkJ Offline
        J.Hilk
        Moderators
        wrote on last edited by
        #3

        additionally to what @Kent-Dorfman said,

        void MainWindow::on_checkBox_stateChanged(int arg1)
        {
            Qt::WindowFlags flags = windowFlags();
            if (ui->checkBox->isChecked())
            flags |= Qt:: WindowStaysOnTopHint;
        }
        

        this also fails to set the new windowFlags to the MainWindow, where's your setWindowFlags(flags); ?


        Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


        Q: What's that?
        A: It's blue light.
        Q: What does it do?
        A: It turns blue.

        1 Reply Last reply
        4
        • Epiales666E Offline
          Epiales666E Offline
          Epiales666
          wrote on last edited by
          #4

          Thank Kent and HIlk... Working .. tytyty

          Be Blessed!
          Epiales666

          1 Reply Last reply
          1

          • Login

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