QML in Qt adventure

on April 5th, 2011 by Wade Shull in Development - Mobile App - QML - Qt
| Share

After buying my Nokia n900 last year I have always had a small interest in writing apps for it.  There were two different problems with this want.  The first was that I didn’t really have a great idea for an app to write.  The second problem is that I am not a programmer by trade.  Another problem arose a few months into owning this incredible phone, Nokia abandoned it.  It was hard for me to justify taking the time to learning a programming language for an operating system that had no future.  With a few months passing by I still felt the itch to develop for this phone. I eventually ran into the website Substance of Code and a programmer that was talking about this new SDK that Nokia just released.  Tommi, the programmer that runs the site, was converting my favorite Twitter client for the n900 over to a new language, QML.  His Twimgo app is amazing in QML.  This inspired me.  One of the advantages of this SDK was that it was cross platform.  I could code for Maemo, Symbian and Meego at the same time.  Finally with an idea in my head I downloaded Qt SDK 1.1 Technical Preview which included QML.

Now it was time for me to learn a new language.  I can manage my way through some HTML and PHP as I need to, but the last time I took a programming class was back in 1999.  That was a C class at Purdue University.  With this version of Qt you can code in C++, QML and JavaScript.  As I started looking through the documentation of QML I saw immediately that this is exactly what I was looking for.  By the definition on their own page:  “QML is a declarative language designed to describe the user interface of a program: both what it looks like, and how it behaves. In QML, a user interface is specified as a tree of objects with properties.”  That is fancy talk for basically saying to me that this language is made to be easy!  I have seen many describe QML as a language for non-programmers.  I would agree with this.  After looking at a few examples and browsing the documentation pages from Nokia, I was on my way to building my first app.  Here is a sample of how easy it can be.

Rectangle {
     id: wholeBlock
     width: 200; height: 200
     color: "blue"
     Text {
          id: textBlock
          anchors.fill: parent
          text: "Example"
     }
}

That little tidbit would show a blue box with the text inside it.  Of course to do a lot more complicated things you need to use JavaScript, which can be imported from another file.  Now as easy as it is, it can also get complicated because of the want of ease.  They have separated some of the commands and functionality into what they are calling Qt Mobility.  This can present some problems, especially with the n900 since they haven’t been updated to the Qt Mobility 1.1 libraries.

Either way that is the story of how I stumbled into QML.  I will be posting little bits here and there as I figure things out.  I have already pulled off some things that people said couldn’t be done through plain QML.  See you can mix QML and C++ in the same program.  I am sure I could learn the C++ portion if I really wanted to, but I really want to try and be a QML purest.  I think it is a powerful language and has lots of potential.  I want to help bring it to North American and show what can really be done.

Comments: 1 Tags:

One Response to “QML in Qt adventure”

  1. I can’t wait for your next posts going over some of the things that you learned cause I know you have some cool tricks to show. Having played with it myself I know how much a pain this can be and the documentation overall isn’t that great so it’s great that you pulled some of the things you did with only QML.

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>