[Qt-qml] Container components in QML

70 views
Skip to first unread message

Miko Kiiski

unread,
Mar 8, 2012, 10:31:29 AM3/8/12
to qt-...@qt.nokia.com
Hi all,

I am trying to create components in QML similar to e.g. QSplitter. I
would need to have a good way of assign the content to the splitter.
Currently I am using the following:

Splitter.qml:

Item {
property alias firstDelegate: firstLoader.sourceComponent
property alias secondDelegate: secondLoader.sourceComponent
...
Loader {
id: firstLoader
}
...
Loader {
id: secondLoader
}
}

If I use the solution above I am able to create the needed
functionality, but using this is a bit difficult and the whole
solution feels a bit cumbersome. The problems with its use surface
when I would need to access the delegates from another component e.g.:

Splitter {
firstDelegate: Rectangle{id: firstRect}
secondDelegate: Rectangle{id: secondRect}
}

Now if I want to access the first & secondRect, I cannot use their
ids, because they are out of scope (?). What I can do is add
properties for the Loader items to the Splitter component. The problem
is that now I assign the delegate using one property and access it
using another, which can make the code hard to understand and also
increase the possibility of mistakes. Another problem that I've had
has been accessing the properties of the delegates (don't know exactly
what is causing this as have not solved the issues fully yet).

So to my question: How should I implement such components? Does it
make any sense to use a Loader component for this?

Cheers,
Miko Kiiski
_______________________________________________
Qt-qml mailing list
Qt-...@qt.nokia.com
http://lists.qt.nokia.com/mailman/listinfo/qt-qml

jens.ba...@nokia.com

unread,
Mar 9, 2012, 2:15:48 AM3/9/12
to miko....@gmail.com, qt-...@qt.nokia.com
I would not recommend using delegates to create such a positioner item for the reasons you pointed out. The Row and Column positioners, essentially do the same as the splitter and do not have a cumbersome API. You might want to look at desktop components, as there is already a SplitterRow/Column component that does exactly this: http://qt.gitorious.org/qt-components/desktop/

Regards,
Jens Bache-Wiig

Miko Kiiski

unread,
Mar 12, 2012, 3:58:46 AM3/12/12
to jens.ba...@nokia.com, qt-...@qt.nokia.com
Hi Jens,

Thanks for the reply! I have looked into the QML Desktop Components,
but the problem with them is that they try to follow the native look
of the OS where as I would like to create something more custom. I
also noticed that the Splitter components in the Desktop Components
are quite complex and my current implementation is much simpler. On
top of that, am not 100% sure about the licences and legal stuff, so
not sure if I could use them anyway.

I suppose the Row and Column might be ok for the Splitter component,
but not work so well with other other components such as menus and
other containers, where I am using the Loaders currently. I am quite
ok with using Loader, if there is no better way to implement those and
if there should not be any issues (other than the cumbersome API) in
using them. But the question is, are there?

Cheers,
Miko Kiiski


2012/3/9 <jens.ba...@nokia.com>:

Reply all
Reply to author
Forward
0 new messages