Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-12565

Switch window type from "normal" to "always on top" and from "always on top" to "normal".

    XMLWordPrintable

Details

    Description

      Nokia says: "this switch required destroy window and recreate window again". But it is not true!!! Below code make this thing flawlessly. So why gorgeous Qt library makie such simple thing very unintuitive and worst than others libraries? Did you ever seen window which suddenly hide and show when you switch "always on top"??? If you did, I strongy recomended don't use such program.

      #include <windows.h>
      void MainWindow::alwaysOnTopSwitch(bool aChecked)
      {
      #ifdef Q_OS_WIN
      //#include <windows.h>
         if(aChecked)
             SetWindowPos(winId(), HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
         else
             SetWindowPos(winId(), HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
      #else
          if(aChecked)
          {
              setWindowFlags(windowFlags() | Qt::CustomizeWindowHint | Qt::WindowStaysOnTopHint);
              show();
          }
          else
          {
              this->setWindowFlags(windowFlags() ^ (Qt::CustomizeWindowHint | Qt::WindowStaysOnTopHint));
              show();
          }
      #endif
      

      Attachments

        1. qtbug12565.zip
          2 kB
        2. alwaysontop.rar
          3 kB

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              kleint Friedemann Kleint
              jacek Jacek
              Votes:
              1 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes