[Qt-qml] Best practices, patterns, etc.

Cornelius Hald hald at icandy.de
Tue Sep 7 12:52:42 CEST 2010


Hi Henrik, 

thanks a lot for the feedback.

On Mon, 2010-09-06 at 22:29 +0200, henrik.hartz at nokia.com wrote:
> You should be able to provide dummydata easily - and you can potentially switch between real and dummy models based on wether the real model is undefined or not - using a ternary operator.

Good idea. I'll do that.

> > Having something like the above, I hope I can create a PersonData C++
> > class and simply replace the QML example data with real data coming from
> > the C++ backend. Does this make sense?
> 
> Yes, and with dummyModel and nativeModel you would use;
> 
> ListView {
> ...
> model: nativeModel==undefined ? dummyModel : nativeModel
> }

Ok.

> > I also thought, that each screen can expose a property like "nextScreen"
> > and whenever this changes the top level component would load this screen
> > using a Loader and then scroll the view to the right.
> > 
> > Again, does this make sense or are there betters ways to do navigation
> > between a number of screens?
> 
> Sounds sensible - and similar to what is implemented in the Qt Components page loader;
> 
>    http://gitorious.org/qt-components/qt-components/blobs/master/examples/meego/pages/main.qml

Thanks for the link. I think I can learn a lot from those components.

> > 4) Currently my screens are simple QML components and it looks like the
> > view elements in QML can only be created using C++. Would I gain
> > anything from implementing my screens as views? If yes, is there some
> > documentation about implementing a view?
> 
> You only use a QDeclarativeView as the App toplevel, and load QML files in this one;
> 
>    http://doc.qt.nokia.com/4.7-snapshot/qdeclarativeview.html#source-prop
> 
> more generally you can find a guide to using QML in C++ applications here
> 
>    http://doc.qt.nokia.com/4.7-snapshot/qtbinding.html
> 
> Generally, the Qt Quick starting page of the docs is pretty covering and should be helpful going forward
> 
>    http://doc.qt.nokia.com/4.7-snapshot/qtquick.html

I've read that documentation already, and I was probably a bit unclear
with the usage of "view". What I meant was: Does it make any sense to
implement a PersonView (like a ListView) that would have a
PersonListModel as model?

Ah that still sounds confused - I guess I simply have to try it :)

Also today I saw the following on Planet Maemo:
http://zchydem.enume.net/2010/09/07/quickflickr-available-at-extras-testing/

I'll have a look at the code and his articles, I guess there's a lot of
good information in it.

Again, thanks and have a nice day!
Conny





More information about the Qt-qml mailing list