QtQuick1.0 vs QtQuick2.0 ?



  • I am beginner to Qt application development framework. I wanted to know, what is the basic difference between QtQuick1.0 and QtQuick2.0 other than API changes i.e, UI interface change.
    What is QML1.0 and QML2.0 ? Read a lot but didn't find exact answer to these questions.

    Please guide me.


  • Moderators

    Wrong subforum, but I don't mind.

    On the outside, the changes are rather cosmetic: most of QtQuick 2 is source compatible with QtQuick 1, porting from one to the other is very easy.

    Internally, they are almost completely different. QtQuick1 uses a raster engine (software rendering), and is based on QGraphicsView, and in turn, on QWidget.

    In QtQuick2, the whole stack is independent from Widgets, and thus much lighter: painting is done using OpenGL based on Gunnar's Scenegraph implementation, V4 engine is used for JavaScript, and there is simply huge amount of new APIs and components available (Qt Quick Controls, better Particle System, Layouts). In short, QtQuick2 is faster and more powerful, but it requires OpenGL to be available on target platform.

    As this description is quite general, please feel free to ask more.



  • Thanks slerdzio for quick response...

    How QML1.0 is different from QML2.0?
    As per my understanding QML1.0 is known as QtDeclarative which is a modelling language used in Qt4.7
    Please confirm if my understanding is correct.

    Is it possible to debug a QML code using Qt Creator IDE ?


  • Moderators

    OK, now. I usually use QtQuick and QtQML interchangeably, but strictly speaking this is wrong. As you correctly point out, QML is another language available in Qt. It's declarative in nature (not imperative like C++ or JavaScript), and similar to CSS/ QSS in syntax.

    QML 1 resides in QtDeclarative module (together with QtQuick1). QML 2 is placed in QtQml module (and QtQuick 2 is separated in QtQuick module).

    Apart from JS backend changes (QML 1 uses QScript, QML 2 in Qt 5.0 and 5.1 uses V8, QML 2 in Qt 5.2 uses the new V4 engine), I'm not aware of any truly major changes to the language itself. There are some updates here and there (var properties, file selectors API, QML Singletons), but for the most part, I think it's the same stuff. You can read lots and lots of gory details at Thomas' blog: "link":http://www.kdab.com/qml-engine-internals-part-1-qml-file-loading/.



  • Thanks sierdzio..

    • How .qml file uses C++ library(QtQuick)? How can I debug it? I come to know about "GammaRay Tool" but still trying to use it but not sure about how much helpful it would be.
    • Is QtQml (QML Engine and language infrastucture) module always used whenever a qml based application is designed ?
    • Is there any basic guildelines to develop a QML application ?
    • What kind of challenges are faced while developing a QML application ?

    Waiting for response..


  • Moderators

    Hi Sam,

    [quote]Is there any basic guildelines to develop a QML application ?[/quote]See

    After you install Qt 5.1.1, create a new project in Qt Creator and select "Qt Quick 2 Application (Built-in Types)".

    [quote]How .qml file uses C++ library(QtQuick)? How can I debug it? I come to know about “GammaRay Tool” but still trying to use it but not sure about how much helpful it would be.[/quote]See:

    (But I suggest getting familiar with simple QML-only apps first, before integrating with C++)

    When you run your app in Qt Creator in Debug mode, it will print debug messages to a console.

    GammaRay is an advanced commercial tool. It will be valuable for large projects, but probably not for small projects or beginner projects.

    [quote]Is QtQml (QML Engine and language infrastucture) module always used whenever a qml based application is designed ?[/quote]Yes.

    [quote]What kind of challenges are faced while developing a QML application ?[/quote]That's a very broad question, which is hard for us to answer without knowing your background. I encourage you to give it a try first, then come back to ask more specific questions.

    Do you have a specific project that you want to create?



  • bq. Do you have a specific project that you want to create?
    Yes.

    -Reusability of exisiting qml.
    If I want to design a SimpleButton.qml with some specific property (like color, font, size, shape, allignment, etc. ) so that it was be used anywhere in the source code wherever I want to have a button in User Interface. How to handle the clicked event on the button if placed on different screens in UI ?


  • Moderators

    [quote]If I want to design a SimpleButton.qml with some specific property (like color, font, size, shape, allignment, etc. ) so that it was be used anywhere in the source code wherever I want to have a button in User Interface. How to handle the clicked event on the button if placed on different screens in UI ?[/quote]Let them emit signals when clicked. There's an example in the "First Steps with QML" tutorial in my last message.



  • In the below code

    @import QtQuick 2.0
    1.Rectangle {

    1. id: colorbutton
    2. width: 200; height: 80;
    3. color: mousearea.pressed ? "steelblue" : "lightsteelblue"    MouseArea {
      
    4.    id: mousearea
      
    5.    anchors.fill: parent
      
    6. }
      9.}
      @

    The code segment 'color: mousearea.pressed ? "steelblue" : "lightsteelblue" ' is a javascript.. how can i write replace it with C++ code.


  • Moderators

    This is getting off-topic. You can add a QObject to the rootContext (as rootContextProperty), and then use Q_INVOKABLE methods, properties and slots from that object in all your QML files, including to assign the colour. You may loose the benefit of bindings this way, though. I do strongly recommend reading the documentation, as JKSH has suggested.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.