我在RPI上使用QML。我的触摸屏有问题。我正在使用Qt 5.9.1并将RPI与VNC连接。当我调试我的gui应用程序时,他们总是在触摸屏上全屏工作,我无法在VNC上看到应用程序窗口。我很好,只有全屏工作,没有在VNC上看到,但如果我触摸屏幕,它可以到达应用程序窗口后面。我的意思是当应用程序处于活动状态时我可能会意外打开桌面应用程序或更改桌面文件我不想再次本地构建Qt因为rpi需要花费很多时间。我的触摸屏如何仅在QML窗口上工作? 谢谢你的回答。 这是main.cpp;
#include "ae2.h"
int main(int argc, char *argv[])
{
QGuiApplication app(argc, argv);
QQmlApplicationEngine engine;
engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
if (engine.rootObjects().isEmpty())
return -1;
Ae2 timer;
QQmlContext* ctx=engine.rootContext();
ctx->setContextProperty("benimHaberciReferansı",&timer);
return app.exec();
}
main qml:
import QtQuick 2.9
import QtQuick.Window 2.2
import QtQuick.Controls 1.3
import QtQuick.Window 2.2
import QtQuick.Dialogs 1.2
import QtQuick.Layouts 1.1
ApplicationWindow {
title: qsTr("Tesla Model S Speedometer")
width: 800//1400
height: 480//600
visible: true
color: "black"
LeftElement {
id: leftRect
y: 50
x: 0
width: parent.width / 2
height: 475
}
RightElement {
id: rightRect
y: 50
x: 400
width: parent.width / 2
height: 475
}
QtObject {
property var locale: Qt.locale()
property date currentDate: new Date()
property string dateString
property string timeString
Component.onCompleted: {
dateString = currentDate.toLocaleDateString();
timeString = currentDate.toLocaleTimeString();
}
}
Image {
width: parent.width
height: parent.height
source: "/pics/Background.png"
}
/* Column {
id: switch1
y: 100
x: 700
Switch { checked: true }
Text {
text: "Mod1"
font.pixelSize: 26
font.bold: true
color: "white"
}
}
Column {
id: switch2
y: 200
x: 700
Switch { checked: true }
Text {
text: "Mod2"
font.pixelSize: 26
font.bold: true
color: "white"
}
}*/
//Leiste unten
Rectangle {
y: parent.height - 90
height: 200
width: parent.width
color: "transparent"
RowLayout {
y: 40
x: 170
Text {
text: "245"
font.pixelSize: 20
font.bold: true
color: "white"
}
Text {
text: "mi"
font.pixelSize: 20
font.bold: false
color: "darkgray"
}
}
RowLayout {
y: 40
x: 100
Text {
text: "69º"
font.pixelSize: 26
font.bold: true
color: "white"
}
Text {
text: "F"
font.pixelSize: 26
font.bold: false
color: "darkgray"
}
}
RowLayout {
y: 40
x: 600
Text {
text: new Date().toLocaleDateString(Qt.locale(),"ddd") //ddd MMM d //h:mm AP
font.pixelSize: 20
font.bold: true
color: "white"
}
Text {
text: new Date().toLocaleDateString(Qt.locale(),"MMM d") //ddd MMM d //h:mm AP
font.pixelSize: 20
font.bold: false
color: "darkgray"
}
}
RowLayout {
y: 40
x: 720
Text {
text: new Date().toLocaleTimeString(Qt.locale(),"h:mm") //ddd MMM d //h:mm AP
font.pixelSize: 20
font.bold: false
color: "darkgray"
}
}
}
//Tacho
Image {
height: parent.height
width: height
x: (parent.width / 2) - (width / 2)
scale: 1.14
source: "/pics/Tacho.png"
fillMode: Image.PreserveAspectFit
}
Speedometer {
height: 525
width: height
x: (parent.width / 2) - (width / 2)
y: (parent.height / 2) - (height / 2)
}
}