On 11/23/2010 01:44 PM, ext Elliot Smith wrote:
> I am trying to figure out if there is a way to create a semi-transparent
> main application window in a QML application.
>
> I've tried setting the color property on my main rectangle like this:
>
> Rectangle {
>    id: window
>    width: 800
>    height: 600
>    color: "transparent"
> }
>
> and also tried "#00000000", but both come up as a solid white block when
> run under the qmlviewer.
>
> I've also tried the -opengl and -frameless flags to qmlviewer in
> desperation, but I guess these won't make any difference (I thought
> maybe the white background was from some default window or maybe because
> I'm not using OpenGL, but I was clutching at straws).
>
> Do I need to create a QtDeclarativeView of my own and run the QML app
> inside that to get a semi-transparent application?

Yes, in addition to setting the top-level QML element to the transparent 
color like you already did.

Here's a the minimal transparent app C++ stub:

QDeclarativeView view;

QPalette palette;
palette.setColor(QPalette::Base, Qt::transparent);
view.setPalette(palette);
view.setAttribute(Qt::WA_TranslucentBackground);

view.setSource(QUrl::fromLocalFile("main.qml"));
view.show();

Regards,
Tomas
_______________________________________________
Qt-qml mailing list
Qt-qml@trolltech.com
http://lists.trolltech.com/mailman/listinfo/qt-qml

Reply via email to