[Qt-qml] How to display QDeclarativeComponent created from C++?
Charley Bay
charleyb123 at gmail.com
Sat Oct 16 22:56:18 CEST 2010
<snip, not have multiple QDeclarativeView instances>,
> instead, have:
>
> QDeclarativeView
> -Desktop-Widget-Canvas
> -QDeclarativeItem
> -QDeclarativeItem
> -QDeclarativeItem
Ah, that makes sense: One "convenience" QDeclarativeView,
and I'll instantiate my QDeclarativeEngine, QDeclarativeContext,
and QDeclarativeItem instances, and I'll merely parent all my
QDeclarativeItem instances inside the *one* QDeclarativeView
convenience instance.
Should I try to figure out how to "share" a single QDeclarativeEngine
instance (I assume there's already one being used by QDeclarativeView
before I create my own)?
Finally, with a single "big" desktop widget, I'd like to make the
background transparent so I can see the rest of my desktop.
I couldn't find any examples in the QML docs, and the "standard"
approaches don't seem to be working, like:
//NOT WORK (app flashes up briefly, then nothing displays):
my_qdeclarative_view.setAttribute(Qt::WA_TranslucentBackground);
my_qdeclarative_view.setWindowFlags(Qt::WindowSystemMenuHint |
Qt::WindowStaysOnTopHint);
QPalette p = my_view.viewport()->palette();
p.setColor(QPalette::Base, Qt::transparent);
my_qdeclarative_view.viewport()->setPalette(p);
...I thought the above should work, because QDeclarativeView
derives from QFrame and QGraphicsView. (What is the root-most
widget?)
The above doesn't work even if I apply them to the "rootObject()"
either. Can you have a transparent QDeclarativeView background
(so I can see the desktop underneath)?
Thanks!
--charley
More information about the Qt-qml
mailing list