现象:qml实时刷新时间的测试demo,在ubuntu上可以正常运行,在ARM 平台不主动刷新,当放大或缩小窗体时,数据更新,之后又不主动刷新。测试widgets可正常运行。
ARM平台环境变量设置如下:
运行平台为Wayland-EGL
main.qml代码如下:
import QtQuick 2.12
import QtQuick.Window 2.12
import QtQuick.Controls 2.5
import QtQml 2.3
Window {
visible: true
width: 300
height: 200
Label{
id: tipLabel
x: 47
y: 0
width: 196
height: 40
// text: currentDateTime();
text: qsTr("MMMMMMMM")
antialiasing: false
enabled: true
z: 0
verticalAlignment: Text.AlignVCenter
horizontalAlignment: Text.AlignHCenter
font.pixelSize: 20
}
function currentDateTime(){
return Qt.formatDateTime(new Date(), "yyyy-MM-dd hh:mm:ss");
}
Timer{
id: timer
interval: 1000 //间隔(单位毫秒):1000毫秒=1秒
running: true
repeat: true //重复
onTriggered: tipLabel.text = currentDateTime()
}
Component.onCompleted: {
timer.start();
}
}
main.cpp代码如下:
#include <QGuiApplication>
#include <QQmlApplicationEngine>
int main(int argc, char *argv[])
{
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QGuiApplication app(argc, argv);
QQmlApplicationEngine engine;
engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
if (engine.rootObjects().isEmpty())
return -1;
return app.exec();
}
.pro代码如下:
QT += qml quick
DEFINES += QT_DEPRECATED_WARNINGS
SOURCES += \
main.cpp
RESOURCES += qml.qrc
QML_IMPORT_PATH =
QML_DESIGNER_IMPORT_PATH =
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target
DISTFILES +=
你好,我是有问必答小助手,非常抱歉,本次您提出的有问必答问题,技术专家团超时未为您做出解答
本次提问扣除的有问必答次数,将会以问答VIP体验卡(1次有问必答机会、商城购买实体图书享受95折优惠)的形式为您补发到账户。
因为有问必答VIP体验卡有效期仅有1天,您在需要使用的时候【私信】联系我,我会为您补发。