QQuickView - resize the content without delay / lag

丶灬走出姿态 提交于 2021-02-20 19:11:21

问题


An image often being the easiest way to explain something, here is a little screengrab of the problem I'm having:

If you look at the right side of the window, you can see that the content is resized with a visible lag / delay. It's a problem that happens in quite a lot of applications, but I was wondering if there is a way to fix this in a Qt application using QQuickView and QML content.

Basically my application is created like this:

QQuickView view;
view.resize(400, 200);
view.setResizeMode(QQuickView::ResizeMode::SizeRootObjectToView);
view.setSource(...);

The QML's content is just an item with 2 rectangles to highlight the problem.

Edit: here is a simplified version of the QML file (yes, the simplified version also suffers from the same problem ;p)

import QtQuick 2.12
Item {
    Rectangle {
        color: "black"
        anchors { fill: parent; margins: 10 }
    }
}

Edit2: Running this small QML snippet through the qmlscene executable also shows the same delay / lag.

Edit3: The same problem occurs on some Linux distros but not on some others: on my Ubuntu it works fine, but on my CentOS 7 is shows the same delay / glitches as on Windows. Both Qt version were 5.12.3. On an old OSX it works fine (tested on Qt 5.9) I'm really lost now ^^

Is there any way to prevent this kind of delay ? The solution will probably be platform specific since it seems the problem comes from the fact that the native frame is resized before Qt has the possibility to get the event, and so the content gets resized with a 1 frame delay ... but I'd like to know if anyone has an idea on how to handle this ?

Any help or pointer appreciated :)

Regards, Damien

来源:https://stackoverflow.com/questions/55923879/qquickview-resize-the-content-without-delay-lag

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!