QWindow的QWidgetAttribute

时间:2013-08-31 14:27:52

标签: qt

剂量任何人都知道如何将Qt :: WidgetAttribute转换为Qt :: WindowFlags ??? 并通过转换我的意思是有任何WidgetAttribute像WA_NoBackground或WA_TranslucentBackground作为WindowFlags的标志.... ???

我一直试图在QML中透明我的ApplicationWindow项目,但我不能。

Main.Qml

import QtQuick 2.1
import QtQuick.Controls 1.0
import QtQuick.Window 2.0

ApplicationWindow {
     title: qsTr("Hello World")
     width: 640
     height: 480
     flags: Qt.SubWindow | Qt.Tool | Qt.FramelessWindowHint | Qt.WindowStaysOnTopHint
     opacity: 0.5
     Image {
           anchors.fill: parent
           source: "blah.png" // and this picture in transparent
     }
}

并且知道我正在寻找像WA_NoBackground和WA_TranslucentBackground

一样的旗帜

Main.cpp的

int main(int argc, char *argv[])
{
     Application app(argc, argv);

     QQmlApplicationEngine engine;
     engine.load(QUrl("blah.qml"));

     QObject *topLevel = engine.rootObjects().value(0);
     QQuickWindow *window = qobject_cast<QQuickWindow *>(topLevel);

     window->show();
     window->setColor(Qt::transparent);

     return app.exec();
}

0 个答案:

没有答案