QWidget中加载QML页面并设置透明背景
生活随笔
收集整理的這篇文章主要介紹了
QWidget中加载QML页面并设置透明背景
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
要在QWidget中加載QML頁(yè)面首先要用到一個(gè)很重要的類QQuickWidget
示例:
m_pQuickWidget = new QQuickWidget(this);m_pQuickWidget->setFixedSize(1131,586);m_pQuickWidget->setAttribute(Qt::WA_AlwaysStackOnTop);m_pQuickWidget->setClearColor(QColor(Qt::transparent));m_pQuickWidget->setSource(QUrl(QStringLiteral("qrc:/UI/Viewer.qml")));m_pQuickWidget->rootObject()->setWidth(1131);m_pQuickWidget->rootObject()->setHeight(586);m_pQuickWidget->move(this->width()/2.0 - m_pQuickWidget->width()/2.0,342);m_pQuickWidget->show();設(shè)置透明,最關(guān)鍵的一句
m_pQuickWidget->setClearColor(QColor(Qt::transparent));總結(jié)
以上是生活随笔為你收集整理的QWidget中加载QML页面并设置透明背景的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: QML中类似QMap的用法
- 下一篇: error LNK2026: 模块对于