QML application on second monitor in Ubuntu
Solved
QML and Qt Quick
-
Hi,
I have written an application with qml and I want it to start in my second monitor, I used this:ApplicationWindow { id: mainAppWindow visible: true visibility : Window.FullScreen minimumWidth: 700 minimumHeight: 350 screen: { for (var i = Qt.application.screens.length-1;i>=0;i--){ if (Qt.application.screens[i].width !== 2560){ print(i) print(Qt.application.screens[i].width) mainAppWindow.screen = Qt.application.screens[i] break } } } }
It works well in windows but when I compile it in Ubuntu environment, it shows the app in my first monitor.
-
Hi PouryaTorabi ,
I don't know the exact reason but I can solve the problem as below.ApplicationWindow { id: mainAppWindow visible: true visibility : Window.FullScreen minimumWidth: 700 minimumHeight: 350 Component.onCompeleted: { for (var i = Qt.application.screens.length-1;i>=0;i--){ if (Qt.application.screens[i].width !== 2560){ print(i) print(Qt.application.screens[i].width) x= Qt.application.screens[i].virtualX; y= Qt.application.screens[i].virtualY; //you don't need below code //mainAppWindow.screen = Qt.application.screens[i] break } } } }
I wish these codes help you.
-
@CKurdu Yes that did help me. There was just a problem that the application would splash in the main window and then would go to the second window. Here is my complete code if any one needed, Thank for your help:
ApplicationWindow { id: mainAppWindow visible: false minimumWidth: 700 minimumHeight: 350 Component.onCompeleted: { for (var i = Qt.application.screens.length-1;i>=0;i--){ if (Qt.application.screens[i].width !== 2560){ print(i) print(Qt.application.screens[i].width) x= Qt.application.screens[i].virtualX; y= Qt.application.screens[i].virtualY; visible = true visibility = Window.FullScreen break } } } }
First i changed the visibility to false and then changed it to true after the screen was set.