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.
  • S SGaist
    15 Mar 2019, 22:44

    Hi,

    What version of Qt ?
    What Linux distribution ?

    0 Offline
    0 Offline
    0...-5
    wrote on 18 Mar 2019, 08:52 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
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 18 Mar 2019, 22:41 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 19 Mar 2019, 15:44
      0
      • K Offline
        K Offline
        Kent-Dorfman
        wrote on 19 Mar 2019, 03:37 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 19 Mar 2019, 15:43
        1
        • K Kent-Dorfman
          19 Mar 2019, 03:37

          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 19 Mar 2019, 15:43 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
          • S SGaist
            18 Mar 2019, 22:41

            What is your graphic hardware ?

            0 Offline
            0 Offline
            0...-5
            wrote on 19 Mar 2019, 15:44 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
            • K Offline
              K Offline
              Kent-Dorfman
              wrote on 19 Mar 2019, 16:51 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 19 Mar 2019, 17:47
              0
              • K Offline
                K Offline
                Kent-Dorfman
                wrote on 19 Mar 2019, 16:54 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
                • K Kent-Dorfman
                  19 Mar 2019, 16:51

                  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 19 Mar 2019, 17:47 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).

                  K 1 Reply Last reply 19 Mar 2019, 18:22
                  0
                  • 0 0...-5
                    19 Mar 2019, 17:47

                    @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).

                    K Offline
                    K Offline
                    Kent-Dorfman
                    wrote on 19 Mar 2019, 18:22 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 19 Mar 2019, 18:44
                    0
                    • K Kent-Dorfman
                      19 Mar 2019, 18:22

                      @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 19 Mar 2019, 18:44 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

                      12/12

                      19 Mar 2019, 18:44

                      • Login

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