我剛開始看Qt Quick,我有一個非常基本的程序,基本上和啓動Qt Quick Controls應用程序項目時一樣。Qt Quick非常緩慢的繪畫
問題是,當我嘗試調整窗口大小時,需要很長時間才能這樣做。這可以在下面的.gif
中看到。
我能找到有類似的問題人們在網絡上的唯一信息是,你可以使用QML探查發現所產生的滯後是在哪裏,有時是由於調試器。所以下面你可以看到QML分析器和gif是在發佈模式下錄製的。
至於我可以告訴動畫鎖定GUI線程了,這是造成渲染或重繪是緩慢的,但我不知道是什麼原因造成的。
我很感謝任何幫助解決這個問題。
並沒有太多的代碼。
Test.pro
QT += qml quick
CONFIG += c++11
SOURCES += main.cpp
RESOURCES += qml.qrc
QML_IMPORT_PATH =
QML_DESIGNER_IMPORT_PATH =
DEFINES += QT_DEPRECATED_WARNINGS
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target
的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(QLatin1String("qrc:/main.qml")));
if (engine.rootObjects().isEmpty())
return -1;
return app.exec();
}
main.qml
import QtQuick 2.7
import QtQuick.Controls 2.0
import QtQuick.Layouts 1.3
ApplicationWindow {
visible: true
width: 640
height: 480
title: qsTr("Hello World")
SwipeView {
id: swipeView
anchors.fill: parent
currentIndex: tabBar.currentIndex
Page1 {
Label {
text: qsTr("First page")
anchors.centerIn: parent
}
}
Page {
Label {
text: qsTr("Second page")
anchors.centerIn: parent
}
}
Page {
Label {
text: qsTr("Third page")
anchors.centerIn: parent
}
}
}
footer: TabBar {
id: tabBar
currentIndex: swipeView.currentIndex
TabButton {
text: qsTr("First")
}
TabButton {
text: qsTr("Second")
}
TabButton {
text: qsTr("Third")
}
}
}
Page1.qml
import QtQuick 2.7
Page1Form {
button1.onClicked: {
console.log("Button Pressed. Entered text: " + textField1.text);
}
}
Page1Form.ui.qml
import QtQuick 2.7
import QtQuick.Controls 2.0
import QtQuick.Layouts 1.3
Item {
property alias textField1: textField1
property alias button1: button1
RowLayout {
anchors.horizontalCenter: parent.horizontalCenter
anchors.topMargin: 20
anchors.top: parent.top
TextField {
id: textField1
placeholderText: qsTr("Text")
}
Button {
id: button1
text: qsTr("Press Me")
}
}
}
規格:的Windows 10,Qt的5.9,MSVC 2017年
我沒有任何問題,像你越來越。窗口調整非常順利。您可能需要仔細檢查其他內容。我使用Qt5.9和Visual Studio 2015. – CroCo
@CroCo好的。謝謝。真奇怪。我不知道視覺工作室版本是否會影響它 – Dan
不確定,但調整窗口大小功能是一件常見的事情。我懷疑QML不能支持這個功能。此外,您使用的應用程序非常簡單,即使極簡單的API也不會出現此症狀。有什麼問題在繼續。 – CroCo