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. Fullscreen over multiple screens (Qt 5.6)

Fullscreen over multiple screens (Qt 5.6)

Scheduled Pinned Locked Moved Unsolved General and Desktop
13 Posts 6 Posters 9.3k Views
  • 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.
  • JohanLJ Offline
    JohanLJ Offline
    JohanL
    wrote on last edited by JohanL
    #1

    I am building a QtQuick application that should mostly run in fullscreen mode, and in some cases using multiple monitors. However, I am unable to get the application to resize to fullscreen over multiple monitors.

    I am currently developing and testing under X11 on Ubuntu 14.04.

    I have been experimenting with setting the geometry of the main window to that of the virtual desktop, and the window actually reports back the correct geometry, but it still only shows up on the primary screen.

    Here is a snippet of what I have been trying.

    int main(int argc, char *argv[])
    {
      QGuiApplication app(argc, argv);
      auto const screen(QGuiApplication::primaryScreen());
    
      QQmlApplicationEngine engine;
      QQmlComponent component(&engine, QUrl(QStringLiteral("qrc:/main.qml")));
    
      auto object = component.create();
      auto window = qobject_cast<QQuickWindow*>(object);
    
      window->setGeometry(screen->availableVirtualGeometry());
    
      return app.exec();
    }
    

    The "window" is a QML ApplicationWindow that has no width och height set initially.

    When running my experiment on a two-screen setup, the application comes up "fullscreen" on one of the screens (seems somewhat random which one, and it is not really fullscreen, as there are still e.g. a window manager menu bar at the top of the screen). However, when logging out the window geometry, it reports back a geometry that would actually cover both the physical screens, i.e. the geometry seems to get set correctly.

    Any ideas and/or pointers?

    Cheers,

    /johan

    --
    Johan Liseborn
    Systems and Application Programmer
    http://www.castlerock.se | Castlerock AB

    ? 1 Reply Last reply
    0
    • JohanLJ JohanL

      I am building a QtQuick application that should mostly run in fullscreen mode, and in some cases using multiple monitors. However, I am unable to get the application to resize to fullscreen over multiple monitors.

      I am currently developing and testing under X11 on Ubuntu 14.04.

      I have been experimenting with setting the geometry of the main window to that of the virtual desktop, and the window actually reports back the correct geometry, but it still only shows up on the primary screen.

      Here is a snippet of what I have been trying.

      int main(int argc, char *argv[])
      {
        QGuiApplication app(argc, argv);
        auto const screen(QGuiApplication::primaryScreen());
      
        QQmlApplicationEngine engine;
        QQmlComponent component(&engine, QUrl(QStringLiteral("qrc:/main.qml")));
      
        auto object = component.create();
        auto window = qobject_cast<QQuickWindow*>(object);
      
        window->setGeometry(screen->availableVirtualGeometry());
      
        return app.exec();
      }
      

      The "window" is a QML ApplicationWindow that has no width och height set initially.

      When running my experiment on a two-screen setup, the application comes up "fullscreen" on one of the screens (seems somewhat random which one, and it is not really fullscreen, as there are still e.g. a window manager menu bar at the top of the screen). However, when logging out the window geometry, it reports back a geometry that would actually cover both the physical screens, i.e. the geometry seems to get set correctly.

      Any ideas and/or pointers?

      Cheers,

      /johan

      ? Offline
      ? Offline
      A Former User
      wrote on last edited by
      #2

      @JohanL Hi, and welcome to the Qt forum! What's your desktop environment? Unity?

      JohanLJ 1 Reply Last reply
      0
      • VRoninV Offline
        VRoninV Offline
        VRonin
        wrote on last edited by
        #3

        have you tried window->showFullScreen() instead of setting the geometry?

        "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
        ~Napoleon Bonaparte

        On a crusade to banish setIndexWidget() from the holy land of Qt

        JohanLJ 1 Reply Last reply
        1
        • ? A Former User

          @JohanL Hi, and welcome to the Qt forum! What's your desktop environment? Unity?

          JohanLJ Offline
          JohanLJ Offline
          JohanL
          wrote on last edited by
          #4

          @Wieland said:

          @JohanL Hi, and welcome to the Qt forum! What's your desktop environment? Unity?

          Thank you!

          Yes, sorry, I should have mentioned, it's Unity.

          --
          Johan Liseborn
          Systems and Application Programmer
          http://www.castlerock.se | Castlerock AB

          JohanLJ 1 Reply Last reply
          0
          • VRoninV VRonin

            have you tried window->showFullScreen() instead of setting the geometry?

            JohanLJ Offline
            JohanLJ Offline
            JohanL
            wrote on last edited by
            #5

            @VRonin said:

            have you tried window->showFullScreen() instead of setting the geometry?

            Yes, I didn't mention that in my original post, but I did try that as well. That actually gives the behavior I really want from the perspective of removing everything but my application from the screen, including any window borders, menu bars, etc, but it still only shows my application on one of my screens.

            I should also mention that things works as expected if I manually resize the window (by dragging at the window borders) to cover the whole screen (or as close as you can get by doing this manually).

            --
            Johan Liseborn
            Systems and Application Programmer
            http://www.castlerock.se | Castlerock AB

            VRoninV 1 Reply Last reply
            0
            • JohanLJ JohanL

              @Wieland said:

              @JohanL Hi, and welcome to the Qt forum! What's your desktop environment? Unity?

              Thank you!

              Yes, sorry, I should have mentioned, it's Unity.

              JohanLJ Offline
              JohanLJ Offline
              JohanL
              wrote on last edited by
              #6

              @JohanL said:

              @Wieland said:

              @JohanL Hi, and welcome to the Qt forum! What's your desktop environment? Unity?

              Thank you!

              Yes, sorry, I should have mentioned, it's Unity.

              Not being an expert in X11 and window managers, I still suspect there might be a connection to window manager behavior. For Unity for example, window maximation (by pressing the little maximize button) also only expands the window on the current screen).

              --
              Johan Liseborn
              Systems and Application Programmer
              http://www.castlerock.se | Castlerock AB

              1 Reply Last reply
              0
              • JohanLJ JohanL

                @VRonin said:

                have you tried window->showFullScreen() instead of setting the geometry?

                Yes, I didn't mention that in my original post, but I did try that as well. That actually gives the behavior I really want from the perspective of removing everything but my application from the screen, including any window borders, menu bars, etc, but it still only shows my application on one of my screens.

                I should also mention that things works as expected if I manually resize the window (by dragging at the window borders) to cover the whole screen (or as close as you can get by doing this manually).

                VRoninV Offline
                VRoninV Offline
                VRonin
                wrote on last edited by
                #7

                @JohanL Looking around it looks like setting the geometry and then calling showFullScreen() worked in Qt4

                "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
                ~Napoleon Bonaparte

                On a crusade to banish setIndexWidget() from the holy land of Qt

                JohanLJ 1 Reply Last reply
                0
                • VRoninV VRonin

                  @JohanL Looking around it looks like setting the geometry and then calling showFullScreen() worked in Qt4

                  JohanLJ Offline
                  JohanLJ Offline
                  JohanL
                  wrote on last edited by
                  #8

                  @VRonin said:

                  @JohanL Looking around it looks like setting the geometry and then calling showFullScreen() worked in Qt4

                  I've now tested this as well, and it does not seem to work either (I tried it both ways, first setting the geometry and then fullscreen, and the other way around). I also failed to mention in my original post that I am on Qt 5.6.

                  I also switched to GNOME, running whatever it is you get by default when installing on Ubuntu 14.04, but same result there, the application only starts in fullscreen on one of the physical screens.

                  --
                  Johan Liseborn
                  Systems and Application Programmer
                  http://www.castlerock.se | Castlerock AB

                  1 Reply Last reply
                  0
                  • VRoninV Offline
                    VRoninV Offline
                    VRonin
                    wrote on last edited by VRonin
                    #9

                    what i'd do then is setting the geometry and then calling

                    window->setFlags(
                    (window->flags() & ~Qt::WindowTitleHint) 
                    | Qt::FramelessWindowHint
                    );
                    

                    This should simulate the apparence of a "full screen" window

                    "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
                    ~Napoleon Bonaparte

                    On a crusade to banish setIndexWidget() from the holy land of Qt

                    JohanLJ 1 Reply Last reply
                    0
                    • VRoninV VRonin

                      what i'd do then is setting the geometry and then calling

                      window->setFlags(
                      (window->flags() & ~Qt::WindowTitleHint) 
                      | Qt::FramelessWindowHint
                      );
                      

                      This should simulate the apparence of a "full screen" window

                      JohanLJ Offline
                      JohanLJ Offline
                      JohanL
                      wrote on last edited by
                      #10

                      @VRonin said:

                      what i'd do then is setting the geometry and then calling

                      window->setFlags(
                      (window->flags() & ~Qt::WindowTitleHint) 
                      | Qt::FramelessWindowHint
                      );
                      

                      This should simulate the apparence of a "full screen" window

                      Yes, this likely works to get the apparence of full screen, except I do not think it will actually make the window cover e.g. the top bar of Ubuntu's Unity desktop.

                      Anyway, I still haven't figured out how to solve the original question of getting my main window to span two (or more) physical screens on startup. I'll continue to dig around, but any additional ideas would be highly appreciated!

                      Cheers,

                      /johan

                      --
                      Johan Liseborn
                      Systems and Application Programmer
                      http://www.castlerock.se | Castlerock AB

                      kshegunovK F 2 Replies Last reply
                      0
                      • JohanLJ JohanL

                        @VRonin said:

                        what i'd do then is setting the geometry and then calling

                        window->setFlags(
                        (window->flags() & ~Qt::WindowTitleHint) 
                        | Qt::FramelessWindowHint
                        );
                        

                        This should simulate the apparence of a "full screen" window

                        Yes, this likely works to get the apparence of full screen, except I do not think it will actually make the window cover e.g. the top bar of Ubuntu's Unity desktop.

                        Anyway, I still haven't figured out how to solve the original question of getting my main window to span two (or more) physical screens on startup. I'll continue to dig around, but any additional ideas would be highly appreciated!

                        Cheers,

                        /johan

                        kshegunovK Offline
                        kshegunovK Offline
                        kshegunov
                        Moderators
                        wrote on last edited by
                        #11

                        @JohanL

                        Yes, this likely works to get the apparence of full screen, except I do not think it will actually make the window cover e.g. the top bar of Ubuntu's Unity desktop.

                        Bear in mind some, or I'd say most, window managers explicitly prohibit that, it can be changed manually from the WM's configuration though (at least KDE allows it, and I think Gnome does as well).

                        I'll continue to dig around, but any additional ideas would be highly appreciated!

                        What I'd try is to get the geometry of each screen, union the regions and ultimately set the widget/window's geometry manually.

                        Kind regards.

                        Read and abide by the Qt Code of Conduct

                        1 Reply Last reply
                        0
                        • JohanLJ JohanL

                          @VRonin said:

                          what i'd do then is setting the geometry and then calling

                          window->setFlags(
                          (window->flags() & ~Qt::WindowTitleHint) 
                          | Qt::FramelessWindowHint
                          );
                          

                          This should simulate the apparence of a "full screen" window

                          Yes, this likely works to get the apparence of full screen, except I do not think it will actually make the window cover e.g. the top bar of Ubuntu's Unity desktop.

                          Anyway, I still haven't figured out how to solve the original question of getting my main window to span two (or more) physical screens on startup. I'll continue to dig around, but any additional ideas would be highly appreciated!

                          Cheers,

                          /johan

                          F Offline
                          F Offline
                          fritzw
                          wrote on last edited by
                          #12

                          @JohanL said in Fullscreen over multiple screens (Qt 5.6):

                          Anyway, I still haven't figured out how to solve the original question of getting my main window to span two (or more) physical screens on startup. I'll continue to dig around, but any additional ideas would be highly appreciated!

                          I know this topic is quite old, but since it's the best match I found, I'll provide a solution anyway. It works on Linux with X11 and xfwm4. The code is PyQt5, but porting it to C++ should be trivial.

                          a = QApplication(sys.argv)
                          widget = QLabel(None)
                          widget.setWindowFlags(Qt.WindowStaysOnTopHint) # optional
                          widget.show() # The order is important. You have to show it BEFORE setting the size.
                          
                          # Negative coordinates are necessary because with (0,0) xfwm will place
                          # the window on the current desktop and below the task bar.
                          taskBarSize = 32
                          allScreens = QApplication.desktop().geometry()
                          widgetSize = allScreens.adjusted(-10, -taskBarSize, 10, taskBarSize)
                          widget.setGeometry(widgetSize) # Now widget should span all screens and cover the task bar
                          
                          a.exec()
                          
                          R 1 Reply Last reply
                          3
                          • F fritzw

                            @JohanL said in Fullscreen over multiple screens (Qt 5.6):

                            Anyway, I still haven't figured out how to solve the original question of getting my main window to span two (or more) physical screens on startup. I'll continue to dig around, but any additional ideas would be highly appreciated!

                            I know this topic is quite old, but since it's the best match I found, I'll provide a solution anyway. It works on Linux with X11 and xfwm4. The code is PyQt5, but porting it to C++ should be trivial.

                            a = QApplication(sys.argv)
                            widget = QLabel(None)
                            widget.setWindowFlags(Qt.WindowStaysOnTopHint) # optional
                            widget.show() # The order is important. You have to show it BEFORE setting the size.
                            
                            # Negative coordinates are necessary because with (0,0) xfwm will place
                            # the window on the current desktop and below the task bar.
                            taskBarSize = 32
                            allScreens = QApplication.desktop().geometry()
                            widgetSize = allScreens.adjusted(-10, -taskBarSize, 10, taskBarSize)
                            widget.setGeometry(widgetSize) # Now widget should span all screens and cover the task bar
                            
                            a.exec()
                            
                            R Offline
                            R Offline
                            Rajprakhar
                            wrote on last edited by
                            #13

                            @fritzw This didn't work for me I also had to add a flag for bypassing window manager, and worked fine if I set the geometry before widget.show() also didn't had to adjust the geometry for the taskbar(tested for KDE only)
                            pyqt5 code:

                            a = QApplication(sys.argv)
                            widget = QLabel(None)
                            widget.setWindowFlags(Qt.WindowStaysOnTopHint | Qt.X11BypassWindowManagementHint)
                            allScreens = QApplication.desktop().geometry()
                            self.setGeometry(allScreens)
                            
                            widget.show()
                            a.exec()
                            
                            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