[Solved]With Qt 5.2, is it possible to make a shaped window with .qml file?
-
In Qt 4.8, QWidget with QDeclarativeView can make a shaped window, with the QWidget settings:
@
setWindowFlags(Qt::FramelessWindowHint);
setStyleSheet("background :transparent;");
setAttribute(Qt::WA_TranslucentBackground, true);
@In Qt 5.2, QQuickView seems different from QDeclarativeView. I tried the same way as in Qt 4.8 but failed.
I found Shaped Clock Example. Is it the only way for Qt 5.2 to make a shaped window?
Thanks in advance.
Cid
-
Under Win 7 64-bit, the following code can show shaped window defined in .qml file.
However, the setMask() of QWindow seems not work, so even the transparent area receives mouse event.
@
#include <QtGui/QGuiApplication>
#include "qtquick2applicationviewer.h"int main(int argc, char *argv[])
{
QGuiApplication app(argc, argv);QQuickView viewer; viewer.setFlags(Qt::FramelessWindowHint); viewer.setColor(QColor(0,0,0,0)); viewer.setSource(QStringLiteral("qml/untitled2/main.qml")); viewer.show(); return app.exec();
}
@