Qt World Summit: Register Today!

Starting to use QT, QML and C++

  • Hello,

    I am a bit dumbfounded. For the past several months I've been teaching myself C++ in order to use QT, but have found that I might have done so in vain, as the new way seems to use QML, but there are also documents that describe how to use C++ and QML together. Could somebody please clear the air? I am also uncertain how to proceed to learn how to use QT. I have looked at the documentation some, and a tutorial, but find it tough going, and I am in sore need of a good book, but all the books available seem to use QT 4.x. It seems there have been a lot of changes in QT 5.x. I'd really rather not learn yet another language if at all possible, but I'd like to learn the best way to go so that I might do some android and IOS programming. Could somebody explain the current best usage of QT? Might somebody also point out somewhere a better way of moving forward to learn it all?

    Thank you very much.

  • Lifetime Qt Champion

    Hi and welcome to devnet,

    The trend is to favor QML but Qt's widgets are not dead at all. As for mixing C++ and QML, the idea is to do all the heavy processing, business logic of your application in C++ and the UI in QML so you have a clear/clean separation between the two.

    Qt's indeed not simple but still, there's a lot of material and tutorial e.g. "VoidRealms":https://www.youtube.com/user/VoidRealms videos.
    Most of what was written for Qt 4 is still valid for Qt 5. The main difference is that the widgets have been moved to their own module and that's what most new users hits when they try book samples.

    "QMLBook":http://qmlbook.org is a good start for QML development.

    If you want to go mobile -> QML. It's a specialized JavaScript language so if you know the later the former should not be too hard to get into.

    On a side note it's Qt, QT stands for Apple QuickTime

  • Hey jac42,

    I'm new to Qt too, just like You I know C++ but I've got some more experience with it, not just a couple of months like You.

    I'm not gonna go into where Qt is going or what is better Qt widgets or QML (because obviously I'm not qualified for that) but I'd like to tell you about my experience with Qt.

    I got my hands on Qt for the first time about a month ago. I started with the links SGaist gave You (voidRealms), great tutorials about Qt widgets and then moved to QML for the same reasons you mentioned(android, ios...development). As for QML itself, I found it pretty easy to learn, syntax is simple and QML looked to me pretty powerful and easy to design flashy, fancy UI plus it supports Javascript functions, variables and stuff.

    Now, like SGaist said, there's Qt's great idea to connect the power of C++ with the simplicity(imho) and rich UI features of QML. As stated the idea is great, I personally like it a lot.

    They way this connection between QML and C++ should work, with Signals and Slots, C++ function invokes....etc, looks pretty simple too. Just the problem is that (always, imo) there's no learning resources on Qt5 in general (btw. just having a discussion about this here). Whenever I had a problem or qustion about Qt I was linked something from the documentation which (again imo because people here seem to disagree with it) is NOT a way for beginners to learn somethig. So it's pretty (at least it was for me) hard for a newbie, like You and me to grasp how these two (QML and C++) are integrated and how the connections actually work.

    I hope You'll find it easier than me to learn Qt because it's a great platfrom.

    Here are some nice QML tutorials from this guy called Joseph. They're made with/for Qt5.2 but work in Qt5.4 just as good.


    Just my two cents.

  • @Homer,

    LOL... Well like you I have C++ experience but mine is dated. I mean REALLY dated. I think the last real C++ program I wrote from start to finish in C++ was in 1995. Since then I've used it here and there for a quick utility.

    Now I'm getting back into it for a fairly large project. I selected Qt because of all the other C++ environments / GUI frameworks, this seemed to be the most complete and well rounded of the frameworks I found. Plus everywhere I turn someone says Qt... So anyway thats why for me is why I'm going to give Qt a good try.

    Like you and probably worse, I need to learn a lot. I think you may be further along than me. I haven't even broken the surface of QML.

  • Thanks everybody,

    Would people recommend that I learn javascript before learning QML? It does't seem to be that difficult a language, although there are some weighty books out there ("[removed] The Definitive Guide" is over 1,000 pages). I'm sure I could find a book that would go over the basics in short order. What do you think?

  • [quote author="JAC42" date="1419913192"]
    Would people recommend that I learn javascript before learning QML? It does't seem to be that difficult a language[/quote]

    If you know C syntax, you already know enough javascript to get started using it in QML. If you plan to keep most logic in C++, it is possible that you won't ever have to "study" javascript at all.

    Most javascript will be oneliner binding expressions like:

    @color: mouseArea.containsMouse ? "red" : "blue"@


    @onClicked: someCppExposedObject.someFunction()@

    While technically javascript, these expressions look the same in C/C++/Java/C# etc.

Log in to reply