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. How to open MainWindow always on top
Forum Updated to NodeBB v4.3 + New Features

How to open MainWindow always on top

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 4 Posters 482 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.
  • J Offline
    J Offline
    JacobNovitsky
    wrote on last edited by
    #1

    If call second time in same application, MainWindow opens in minimized Window, so I need to click its icon on toolbar or alt+tab
    I would better explicitly set it to always open on top
    please advise

    P C CKurduC 3 Replies Last reply
    0
    • J JacobNovitsky

      If call second time in same application, MainWindow opens in minimized Window, so I need to click its icon on toolbar or alt+tab
      I would better explicitly set it to always open on top
      please advise

      P Offline
      P Offline
      papinhio
      wrote on last edited by
      #2

      @JacobNovitsky Can you please provide some code please?

      1 Reply Last reply
      0
      • J JacobNovitsky

        If call second time in same application, MainWindow opens in minimized Window, so I need to click its icon on toolbar or alt+tab
        I would better explicitly set it to always open on top
        please advise

        C Offline
        C Offline
        ChrisW67
        wrote on last edited by
        #3

        @JacobNovitsky QWidget::showNormal(), QWidget::showMaximized(), QWidget::raise(), QWidget::activateWindow().

        1 Reply Last reply
        0
        • J JacobNovitsky

          If call second time in same application, MainWindow opens in minimized Window, so I need to click its icon on toolbar or alt+tab
          I would better explicitly set it to always open on top
          please advise

          CKurduC Offline
          CKurduC Offline
          CKurdu
          wrote on last edited by CKurdu
          #4

          @JacobNovitsky
          Maybe a silly question but
          Did you use setWindowFlags(Qt::WindowStaysOnTopHint) ?

          #include <QApplication>
          #include <QMainWindow>
          
          int main(int argc, char *argv[]) {
              QApplication app(argc, argv);
          
              QMainWindow mainWindow;
              mainWindow.setWindowTitle("Example Top App");
          mainWindow.setWindowFlags(Qt::WindowStaysOnTopHint);
          
              mainWindow.show();
          
              return app.exec();
          }
          
          

          If you are on Linux OS, document also says

          "Informs the window system that the window should stay on top of all other windows. Note that on some window managers on X11 you also have to pass Qt::X11BypassWindowManagerHint for this flag to work correctly."

          You reap what you sow it

          1 Reply Last reply
          0

          • Login

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