Fullscreen over multiple screens (Qt 5.6)
-
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
-
@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).
-
@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).
-
@VRonin said:
@JohanL Looking around it looks like setting the geometry and then calling
showFullScreen()
worked in Qt4I'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.
-
@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
-
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.
-
@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()
-
@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()