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. QGuiApplication::screens() problem
QtWS25 Last Chance

QGuiApplication::screens() problem

Scheduled Pinned Locked Moved Unsolved General and Desktop
qguiapplicationscreenlinux
12 Posts 3 Posters 5.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.
  • 0 Offline
    0 Offline
    0...-5
    wrote on last edited by 0...-5
    #1

    I'm working on debian-based OS. There are 2 DVI monitors, but when I call `
    QGuiApplication::screens() it returns a list with only one item.
    I tryed to execute shell commands and that is what I got:

    DISPLAY=:0 xrandr

    Screen 0: minimum 8 x 8, current 1280 x 2048, maximum 32767 x 32767
    DVI1 connected primary 1280x1024+0+1024 (normal left inverted right x axis y axis) 380mm x 300mm
       1280x1024     60.02*+  75.02  
       1280x1024_60.0  60.02  
       1152x864      75.00    59.97  
       1024x768      75.03    70.07    60.00  
       832x624       74.55  
       800x600       72.19    75.00    60.32    56.25  
       640x480       75.00    72.81    66.67    59.94  
       720x400       70.08  
    DVI2 unknown connection 1280x1024+0+0 (normal left inverted right x axis y axis) 0mm x 0mm
       1280x1024     60.02 +
       1280x1024_60.0  60.02* 
    VIRTUAL1 disconnected (normal left inverted right x axis y axis)
    

    DISPLAY=:0 xrandr —listactivemonitors

    0: +*DVI1 1280/380x1024/300+0+1024  DVI1
    1: +DVI2 1280/339x1024/271+0+0  DVI2
    

    Is there a way to fix it?

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

      Hi,

      What version of Qt ?
      What Linux distribution ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      0 1 Reply Last reply
      0
      • SGaistS SGaist

        Hi,

        What version of Qt ?
        What Linux distribution ?

        0 Offline
        0 Offline
        0...-5
        wrote on last edited by
        #3

        @SGaist here it is:
        qmake -v

        QMake version 3.1
        Using Qt version 5.9.7 in /usr/lib
        

        /proc/version

        Linux version 4.14.103 (ubuntu@ole) (gcc version 6.4.0 (GCC)) #1 SMP PREEMPT Sun Mar 17 17:47:26 UTC 2019
        
        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          What is your graphic hardware ?

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          0 1 Reply Last reply
          0
          • Kent-DorfmanK Offline
            Kent-DorfmanK Offline
            Kent-Dorfman
            wrote on last edited by Kent-Dorfman
            #5

            It's because you're using twinview or xinerama. That maps the multiple screens into one virtual desktop under a single DISPLAY variable whos dimensions are the sum of all available monitors. I run multiple monitors, but each one is a separate DISPLAY (:0.0 and :0.1)

            0 1 Reply Last reply
            1
            • Kent-DorfmanK Kent-Dorfman

              It's because you're using twinview or xinerama. That maps the multiple screens into one virtual desktop under a single DISPLAY variable whos dimensions are the sum of all available monitors. I run multiple monitors, but each one is a separate DISPLAY (:0.0 and :0.1)

              0 Offline
              0 Offline
              0...-5
              wrote on last edited by
              #6

              @Kent-Dorfman no, it is not. If I call QGuiApplication::screens().first()->availableGeometry() I will get a rect matching to one of my screens, not their sum

              1 Reply Last reply
              0
              • SGaistS SGaist

                What is your graphic hardware ?

                0 Offline
                0 Offline
                0...-5
                wrote on last edited by
                #7

                @SGaist I can fetch lspci | grep VGA, is it enough?

                00:02.0 VGA compatible controller: Intel Corporation Mobile 945GM/GMS, 943/940GML Express Integrated Graphics Controller (rev 03)
                
                1 Reply Last reply
                0
                • Kent-DorfmanK Offline
                  Kent-DorfmanK Offline
                  Kent-Dorfman
                  wrote on last edited by
                  #8

                  from the documention...

                  availableVirtualGeometry : const QRect
                  
                  This property holds the available geometry of the virtual desktop to which this screen belongs
                  
                  Returns the available geometry of the virtual desktop corresponding to this screen.
                  
                  This is the union of the virtual siblings' individual available geometries.
                  
                  Access functions:
                  QRect 	availableVirtualGeometry() const
                  
                  Notifier signal:
                  void 	virtualGeometryChanged(const QRect &rect)
                  
                  See also availableGeometry() and virtualSiblings().
                  

                  I know X11 quite well. Trust me on this.

                  0 1 Reply Last reply
                  0
                  • Kent-DorfmanK Offline
                    Kent-DorfmanK Offline
                    Kent-Dorfman
                    wrote on last edited by
                    #9

                    and...

                    QList<QScreen *> QGuiApplication::screens()
                    
                    Returns a list of all the screens associated with the windowing system the application is connected to.
                    

                    What happens to your QList<QScreen> if your app has two windows and one window is on each physical display. I bet ya in that case the list has two entries.

                    1 Reply Last reply
                    0
                    • Kent-DorfmanK Kent-Dorfman

                      from the documention...

                      availableVirtualGeometry : const QRect
                      
                      This property holds the available geometry of the virtual desktop to which this screen belongs
                      
                      Returns the available geometry of the virtual desktop corresponding to this screen.
                      
                      This is the union of the virtual siblings' individual available geometries.
                      
                      Access functions:
                      QRect 	availableVirtualGeometry() const
                      
                      Notifier signal:
                      void 	virtualGeometryChanged(const QRect &rect)
                      
                      See also availableGeometry() and virtualSiblings().
                      

                      I know X11 quite well. Trust me on this.

                      0 Offline
                      0 Offline
                      0...-5
                      wrote on last edited by 0...-5
                      #10

                      @Kent-Dorfman I'm not pretending to know X11 well, that's true. But when I executed DISPLAY=:0 xrandr I got two screens associated with on DISPLAY. And when I executed DISPLAY=:0 <path_to_my_app> it recognized only one screen.
                      Moreover that, I have forced my app to render a window on the "unexisting" screen and it worked. But all top-level widgets like context menus are drawn on the second ("existing") screen (because they are using global coordinate system I think).

                      Kent-DorfmanK 1 Reply Last reply
                      0
                      • 0 0...-5

                        @Kent-Dorfman I'm not pretending to know X11 well, that's true. But when I executed DISPLAY=:0 xrandr I got two screens associated with on DISPLAY. And when I executed DISPLAY=:0 <path_to_my_app> it recognized only one screen.
                        Moreover that, I have forced my app to render a window on the "unexisting" screen and it worked. But all top-level widgets like context menus are drawn on the second ("existing") screen (because they are using global coordinate system I think).

                        Kent-DorfmanK Offline
                        Kent-DorfmanK Offline
                        Kent-Dorfman
                        wrote on last edited by
                        #11

                        @0...-5 said in QGuiApplication::screens() problem:

                        @Kent-Dorfman I'm not pretending to know X11 well, that's true. But when I executed DISPLAY=:0 xrandr I got two screens associated with on DISPLAY. And when I executed DISPLAY=:0 <path_to_my_app> it recognized only one screen.
                        Moreover that, I have forced my app to render a window on the "unexisting" screen and it worked. But all top-level widgets like context menus are drawn on the second ("existing") screen (because they are using global coordinate system I think).

                        Read the definition of screens() closely. You have ONE X11 DISPLAY that spans two distinct monitors and gives you a virtual desktop that is the sum of both physical displays.

                        if you open an xterm in each physical display and do echo $DISPLAY you should see the same value returned for each. that means your system is configured for a single large virtual desktop, as is the common config in linux these days. screens() only returns the physical display that contains your running app. If you have a multiwindow app with one window in each monitor, or have a single window that spans both monitors then screens() should return a two entry QList.

                        0 1 Reply Last reply
                        0
                        • Kent-DorfmanK Kent-Dorfman

                          @0...-5 said in QGuiApplication::screens() problem:

                          @Kent-Dorfman I'm not pretending to know X11 well, that's true. But when I executed DISPLAY=:0 xrandr I got two screens associated with on DISPLAY. And when I executed DISPLAY=:0 <path_to_my_app> it recognized only one screen.
                          Moreover that, I have forced my app to render a window on the "unexisting" screen and it worked. But all top-level widgets like context menus are drawn on the second ("existing") screen (because they are using global coordinate system I think).

                          Read the definition of screens() closely. You have ONE X11 DISPLAY that spans two distinct monitors and gives you a virtual desktop that is the sum of both physical displays.

                          if you open an xterm in each physical display and do echo $DISPLAY you should see the same value returned for each. that means your system is configured for a single large virtual desktop, as is the common config in linux these days. screens() only returns the physical display that contains your running app. If you have a multiwindow app with one window in each monitor, or have a single window that spans both monitors then screens() should return a two entry QList.

                          0 Offline
                          0 Offline
                          0...-5
                          wrote on last edited by 0...-5
                          #12

                          @Kent-Dorfman I'm sorry, but I steel don't get it...I have two physical monitors each of which is 1280x1024px. If they span into one display I should get a screen with 1280x2048 resolution, shouldn't I? But my screens list contains one an entity with {0, 1024, 1280, 1024} rect for available geometry. I can test what returns availableVirtualGeometry method tomorrow in the office, but no matter it does I can't find a way to render a GUI on the second physical monitor properly.

                          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