kinetic-declarative plasma integration

Marco Martin notmart at
Fri May 15 15:34:32 CEST 2009

On Friday 15 May 2009, aaron.kennedy at wrote:
> Hi Marco,
> On 15/05/09 7:10 AM, "ext Marco Martin" <notmart at> wrote:
> >>> * if one wants to create QML items dynamically, e.g. when a DataEngine
> >>> returns a source create a new QML item and load it, how does that work
> >>> exactly? can that be done from a JavaScript file?
> >>
> >> We have a couple of ways of dealing with "lists" of things (which sounds
> >> like what the sources returned from a dataengine conceptually are).  All
> >> of our view classes can take sets of things, and we also have a
> >> generalized "Repeater" element for handling other cases.
> >
> > i'm indeed playing with views now.
> > since the qml documentation appears still not there i'm going by
> > attempts: what classes are for views? until now i've found ListView and
> > GridView, anything else?
> > also, is it possible to do an horizontal list view?
> > but the real question is: is it possible somehow to plug a traditional qt
> > model into it?
> The documentation is still a work in progress.  In the specific case of the
> views available, however, I think its ok.  From the main page, navigate to
> "Declarative Module"/"Qml Elements" and then look under the "Views"
> heading.
> Incase you haven't generated the documentation, but want to get going fast,
> here are the specific answers to your questions :)
> You can set a ListView into horizontal mode by setting the "orientation"
> property, like this:
> ListView {
>     orientation: "Horizontal"
> }

tanks a lot for the input on qmodels, i assumed the qt docs were missing on 
that part, now i've generated them and i see..

what i'm looking about specifically is seeing how feasible is to use those 
list views in the gsoc i'm mentoring about a plasma based mediacenter (well, 
depends also when we want to release something, before or after 4.6)

so i'm looking on what we would need in that case:

doesn't seems to be any way to set the currentIndex of any of the views simply 
by clicking on an item (can implement a mouseRegion on the delegate, but 
doesn't seem to be a way for the item to know what is its index into the 

PathView doesn't seem to be controllable with the keyboard (even by 
implementing KeyActions into the delegate and changing the active index 
doesn't seem to work, but nothing automatic anyways)

is there a way for an item to notice when it becomes active and changing its 
state as a consequence? i.e, having the active item maybe slightly bigger and 
with more info, like the recipes example (but here the item zooming is 
triggered by a mouse click)

Marco Martin

> You can plug a QAbstractItemModel Qt model into our views, with one small
> extra step.  Because we expose each model role as a JavaScript property,
> not an integer enumeration value, we need a way to map between the role
> ints in your C++ model and textual representations.  We've added a "void
> QAbstractItemModel:: setRoleNames(const QHash<int,QByteArray> 
> method to let you specify this mapping.
> So, to hook this all up:
> // Setup role mapping
> QHash<int, QByteArray> roleNames;
> roleNames.insert(1023, "myRoleName");
> myModel->setRoleNames(roleNames);
> // Bind the C++ model instance into a QML context
> QmlContext *context = new QmlContext(engine->rootContext());
> context->setContextProperty("myModel", static_cast<QObject *>(myModel));
> // This is the example QML text that we'll instantiate
> #define QML_TEXT "Rect { color: "white"; ListView { anchors.fill: parent;
> delegate: Text { text: myRoleName } model: myModel } }"
> // Create a QML component that uses the model
> QmlComponent component(engine, QML_TEXT);
> component->create(context);
> This will give you a fairly boring list containing the text of the
> "myRoleName" role for each entry in your model.
> Cheers,
> Aaron
> _______________________________________________
> Plasma-devel mailing list
> Plasma-devel at

More information about the Plasma-devel mailing list