QML two display problem
-
Good afternoon.
I decided to dive into QML a bit.I have a C++ backend that is properly communicating with the QML frontend. It all works just fine but one problem I can't figure out.
The idea is that the application has two screens available:
- the main screen, which is a touch screen - on it runs a stack view with controls and such (I started to code it, it runs just fine).
- the "display screen", where is just one fullscreen window with data display (again, I have that coded and works just fine).
Problem is that I would like to join those two in a single program. From the documentation I figure, that setting the
screen
option usingQt.application.screens
array values is the way to go but when I set it all the views are on just one screen (arrayQt.application.screens
has two entries, as expected and both return expected screen sizes). My main.qml file:import QtQuick 2.11 import QtQuick.Window 2.11 import QtQuick.Controls 2.4 import QtQuick.Controls.Material 2.3 import QtQuick.VirtualKeyboard 2.3 import BackEnd 1.0 ApplicationWindow { id: appwindow visible: true screen: Qt.application.screens[1] width: screen.width height: screen.height title: qsTr("Large") BackEnd { id: backend } Window { id: mainwindow screen: Qt.application.screens[0] width: screen.width height: screen.height visible: true } header: Text { Text { text: "Control panel" horizontalAlignment: Text.AlignHCenter verticalAlignment: Text.AlignVCenter } } footer: status StackView { id: cfg visible: true anchors.fill: parent initialItem: ConfigWindow Connections { target: backend onProgressStart: { push(progres); pHeaderText.text=backend.progressHeader; pFooterText.text=backend.progressFooter; } onProgressStop: pop(progres) } } Item { id: status Text { text: "Status: "+backend.status verticalAlignment: Text.AlignVCenter horizontalAlignment: Text.AlignHCenter } } Page { id: progres anchors.fill: parent header: Text { id: pHeaderText verticalAlignment: Text.AlignVCenter horizontalAlignment: Text.AlignHCenter } footer: Text { id: pFooterText verticalAlignment: Text.AlignVCenter horizontalAlignment: Text.AlignHCenter } ProgressBar { id: bar value: 0 from: 0 to: 100 } Connections { target: backend onProgressChanged: bar.value=backend.progressValue } } Component.onCompleted: { //not important here } }
-
@artwaw what platform do you target ?
I assume you're using a version of Qt 5.11 (according to the imports)
I tried the following:
import QtQuick 2.12 import QtQuick.Window 2.12 import QtQuick.Controls 2.12 ApplicationWindow { id: appWindow screen: Qt.application.screens[1] visible: true width: 400 height: 100 Window { id: mainwindow screen: Qt.application.screens[0] width: screen.width height: screen.height visible: true } }
on macOS (BigSur) with Qt 5.12.6 and I get both windows on different screens, one "full screen" and one not, like expected
-
-
Try using a
QtObject
as a root object and 2 childWindow
/ApplicationWindow
in it.