Qt Quick 很慢的绘画 [英] Qt Quick very slow painting

查看:43
本文介绍了Qt Quick 很慢的绘画的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚开始研究 Qt Quick,我有一个非常基本的程序,与您启动 Qt Quick Controls 应用程序项目时基本相同.

I have just started to look at Qt Quick and I have a very basic program, essentially the same as when you start a Qt Quick Controls application project.

问题是当我尝试调整窗口大小时需要很长时间.这可以在下面的 .gif 中看到.

The problem is when I try to resize the window it takes a very long time to do so. This can be seen in the .gif below.

我在网上能找到的关于有类似问题的人的唯一信息是,您可以使用 QML Profiler 查找产生延迟的位置,有时是由于调试器造成的.所以下面你可以看到 QML 分析器和 gif 是在发布模式下录制的.

The only information I could find on the web about people having a similar problem was that you could use the QML Profiler to find where the lag is being generated and sometimes it is due to the debugger. So below you can see the QML profiler and the gif was recorded in release mode.

据我所知,动画正在锁定 GUI 线程,这导致渲染或重绘变慢,但我不确定是什么原因造成的.

As far as I can tell the animation is locking the GUI thread up which is causing the render or repainting to be slow but I am not sure what is causing it.

如果您能帮助我解决问题,我将不胜感激.

I would appreciate any help in solving the problem.

而且代码不多.

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

ma​​in.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();
}

ma​​in.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


Specs: Windows 10, Qt 5.9, MSVC 2017

Qt 论坛交叉帖子

推荐答案

最近这个 Qt Bug 已经修复,从 5.9.2 开始:https://bugreports.qt.io/browse/QTBUG-59893

Recently this Qt Bug was fixed, since 5.9.2: https://bugreports.qt.io/browse/QTBUG-59893

此修复程序是否解决了此问题?

Does this fix solve this issue?

这篇关于Qt Quick 很慢的绘画的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆