Qt Widget vs. Qt Quick/QML ?
-
wrote on 25 May 2014, 22:19 last edited by
I am new to Qt and just went through these two tutorials:
Getting Started Programming with Qt Widgets | QtDoc 5.3
http://qt-project.org/doc/qt-5/gettingstartedqt.htmlCreating Qt Quick Projects | QtCreator
http://qt-project.org/doc/qtcreator-3.1/quick-projects.htmlThe Qt Widgets seem to have a more complete set of widgets like buttons etc., but the Qt Designer seems half baked, for example the field for the font size is unnecessarily wide and the up and down arrows for adjusting are way over on the right and tiny.
On the other hand, the Qt Quick Designer looks much more polished but is lacking even the most basic button - in the tutorial a button is made out of a rectangle plus a mouse clicking area with multiple manual steps involved.
I am mainly interested in Android and will need to define my own widgets, which one is better suited: Qt Quick or Qt Widgets?
Thanks in advance!
-
Hi,
Since you are developing for Android, I recommend Qt Quick. Qt Quick was designed specifically with mobile touchscreen devices, and supports features that people expect from smartphones/tablets, like animated transitions and graphical effects. Widgets currently look horrible on Android.
Also, QML (the language used to by Qt Quick) makes it very easy to write custom GUI components.
However, if you were developing a traditional desktop office-style application, I would recommend Qt Widgets. It is more mature than Qt Quick and makes life easier for desktop app developers.
[quote]On the other hand, the Qt Quick Designer looks much more polished but is lacking even the most basic button – in the tutorial a button is made out of a rectangle plus a mouse clicking area with multiple manual steps involved.[/quote]The tutorial is outdated. See "Qt Quick Controls":http://qt-project.org/doc/qt-5/qtquickcontrols-index.html for these basic components.
I also think that tutorial is overly complex for "getting started" level. I recommend this "QML Tutorial":http://qt-project.org/doc/qt-5/qml-tutorial.html -- it's much easier to follow.
-
wrote on 26 May 2014, 18:05 last edited by
Thank you so much for the detailed explanation! I will give the tutorials a try.
-
wrote on 26 May 2014, 20:37 last edited by
Actually one more question about QML: Is it some kind of interpreted (thus slow?) language? I had one occasion that some miss-placed brackets weren't caught by the compiler and caused error only at run time. The question is whether it performs as fast as native C++ code. I will have dozens of custom widgets, each will be doing hundreds of drawing operations per frame and the hope is to have at least 30 frames per second. (Each widget shows an X-Y plot of hundreds of data points that change with time.) Will QML be able to handle that?
-
wrote on 26 May 2014, 21:10 last edited by
QML is a scripting language.
I didn't test how much is slow respect to the same thing done in pure C++ code.
But, for what concerns your problem I think that QML can handle that otherwise Qt Digia would not offer the following products via QML:http://qt.digia.com/Product/Qt-Enterprise/Value-Add-Features/Charts/
http://qt.digia.com/Product/Qt-Enterprise/Value-Add-Features/Advanced-Data-Visualization/So, the question is how QML can handle that :-) ... and I don't know.
-
wrote on 26 May 2014, 22:45 last edited by
Thanks for the comment. Those look like static data charts, which are much less demanding than dynamic data charts updating at 30 fps.
-
You're welcome :)
[quote author="aqtdummy" date="1401136622"]Actually one more question about QML: Is it some kind of interpreted (thus slow?) language? I had one occasion that some miss-placed brackets weren't caught by the compiler and caused error only at run time. The question is whether it performs as fast as native C++ code. I will have dozens of custom widgets, each will be doing hundreds of drawing operations per frame and the hope is to have at least 30 frames per second. (Each widget shows an X-Y plot of hundreds of data points that change with time.) Will QML be able to handle that?[/quote]Why do you equate "interpreted" with "slow"? For example, "Julia":http://julialang.org/benchmarks/ is an interpreted language which is on par with C and Fortran, and blows Go (another compiled language) out of the water.
Your code structure has a big influence, it's not just about interpreted vs. compiled.
Anyway, yes QML is an interpreted language with a JIT compiler. Qt Quick items are rendered by the GPU, while Qt Widgets are rendered by the CPU. So generally, Qt Quick is faster than C++ widgets.
For computationally-intensive rendering like what you've described, your caution is valid: pure QML might not handle it well. However, you can implement your code directly in C++/OpenGL via the "Qt Quick Scene Graph":http://qt-project.org/doc/qt-5/qtquick-visualcanvas-scenegraph.html. Here is an "example":http://qt-project.org/doc/qt-5/qtquick-scenegraph-openglunderqml-example.html.
By the way, I recommend that you install the "Qt 5 Everywhere":https://play.google.com/store/apps/details?id=com.digia.Qt5Everywhere demo app on your Android device and try it out. It's written in pure QML but still features some impressive graphical effects (notably particles) Source code at https://qt.gitorious.org/qt-labs/qt5-everywhere-demo/source/QtDemo
[quote author="Gianluca" date="1401138609"]QML is a scripting language.[/quote]It's more accurate to say that QML is a hybrid language that combines "Object Notation" with "Scripting". It has declarative and imperative parts.
[quote author="aqtdummy" date="1401144303"]Thanks for the comment. Those look like static data charts, which are much less demanding than dynamic data charts updating at 30 fps.[/quote]Did you watch the video in the Advanced Data Visualization page that Gianluca linked? Focus on 2:20-2:40
-
wrote on 30 May 2014, 01:18 last edited by
Thank you so much again for taking the time to write such informative reply! I will go through the suggestions and come back later for more questions for sure. :)
1/8