QGuiApplication::screens() problem
-
What is your graphic hardware ?
-
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)
-
@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
-
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.
-
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.
-
@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). -
@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.
-
@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.