How to make a transparent window with Qt Quick?

前端 未结 4 686
一生所求
一生所求 2020-12-24 02:30

Is there a way to make the window of a qml application transparent?

I\'m looking for a detailed description on how to draw simple s

4条回答
  •  失恋的感觉
    2020-12-24 02:53

    I'm using Qt 5.3 with both C++ and QML and found that I needed to call QQuickWindow::setDefaultAlphaBuffer. This has to be done before creating the first QQuickWindow, so in C++, not QML. The window color and flags could probably be set in QML, but I opted to put all the code for winow transparency in one place like so:

    QQuickView view;
    QQuickWindow::setDefaultAlphaBuffer(true);
    view.setColor(Qt::transparent);
    view.setFlags(m_View.flags() | 
                  static_cast(Qt::WA_TranslucentBackground));
    

提交回复
热议问题