简体   繁体   English

Qml在无框架QQuickView(QtQuick2)中的动画上闪烁

[英]Qml flicker on animation in frameless QQuickView (QtQuick2)

main.cpp main.cpp

#include <QGuiApplication>
#include <QQuickView>

int main(int argc, char *argv[])
{
    QGuiApplication app(argc, argv);
    QQuickView *view= new QQuickView;
    view->setFlags(Qt::Tool|Qt::WindowStaysOnTopHint|Qt::FramelessWindowHint);
    view->setColor(Qt::transparent);
    view->show();
    view->setSource(QUrl(QStringLiteral("qrc:/main.qml")));
    return app.exec();
}

qmlfile: qmlfile:

import QtQuick 2.0

Rectangle {
    width: 100
    height: 100
    color: "#80808080"

    Rectangle {
        width: 10
        height: 10
        anchors.centerIn: parent
        RotationAnimation on rotation {
            duration : 15000
            easing.type: Easing.Linear
            loops: Animation.Infinite
            from: 0
            to: 360
        }
    }
}

The transparent background flickers , but only with an animation. 透明背景闪烁 ,但仅带有动画。 The example is pretty basic, so whats the problem? 这个例子很基本,那又是什么问题呢?

Short answer: Set the environment variable to QSG_RENDER_LOOP=basic 简短答案:将环境变量设置为QSG_RENDER_LOOP = basic

Long answer: I dont know the exact internals. 长答案:我不知道确切的内部构造。 The Qmlscene is rendered by multiple threads when QSG_RENDER_LOOP=threaded is set. 设置QSG_RENDER_LOOP = threaded时,多个线程将呈现Qmlscene。 But some drivers fail in rendering smooth animations. 但是某些驱动程序无法渲染流畅的动画。 Hence for untested systems (x11,mesa) initially QSG_RENDER_LOOP was set to basic. 因此,对于未经测试的系统(x11,mesa),最初QSG_RENDER_LOOP设置为基本。 Since 5.5 threaded is the default. 由于5.5线程是默认设置。

Try "view->setFlags(Qt::SplashScreen)" Maybe solve this issue, but the window can't be resized and moved. 尝试“ view-> setFlags(Qt :: SplashScreen)”也许可以解决此问题,但是无法调整窗口大小和移动窗口。 It doesn't make sense, but it is. 这没有道理,但确实如此。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM