Hi Marius, On 23 April 2014 23:07, cincirin <[email protected]> wrote: > On 4/23/2014 5:50 PM, Sze Howe Koh wrote: >> >> With QML, the general idea is to use QML for the GUI and use C++ for core >> logic. > > Well from I understand QML is used in a lot of other aspects than GUI: Qt > WebKit 2 is QML ( only ? ), also QML is used in multimedia, position modules > and so on ...
Yes, that's true. I think WebKit 2 and 3D audio are the odd ones out though (I'm not sure why they did this -- we'll have to ask the devs). Nokia invented QML for the purpose of GUI development, but I guess people find it convenient to be able to access non-graphical features directly from QML. Except for graphics, WebKit 2 and 3D audio, all other QML features (including other multimedia features and Qt Positioning) are simply a QML counterpart to C++ features. > It's absolute clear that if you want to manually edit the UI file, there's > no point to compare the solutions, QML is preferred instead of writing xml > mannually. > But what I meant is to create the UI file with some specific UI editor like > QtDesigner or Android UI editor. You don't have to write the file manually. Have you seen Qt Quick Designer? http://qt-project.org/doc/qtcreator-3.1/creator-using-qt-quick-designer.html It doesn't matter whether your file is .ui or .qml -- you can use a visual editor and you don't need to modify the files directly to create your UI. (Of course, you'd still need to implement slots and signal handlers in C++ and QML respectively) > So what I don't understand why Android xml file can be the most efficient > way to define the UI for that platform for many developers, and why we are > somehow forced to abandon QtDesigner UI (xml) files in favor of QML. To understand this, you need to look at Qt's history. Here is a simple timeline of Qt UI technologies: 1995 -- (C++) -- Widgets introduced 2006 -- (C++) -- Graphics View Framework introduced 2010 -- (QML) -- Qt Quick 1 introduced, built on the Graphics View Framework. 2012 -- (QML) -- Qt Quick 2 introduced, built on a new OpenGL framework. The Graphics View Framework supports UI technologies which are important to many modern platforms, such as animated transitions. Widgets don't support these techs easily (you need to write lots of code to make it work). Android was released in 2008 and Android XML files were designed for modern UI techs. In contrast, Qt's .ui XML files can only assemble Widget-based GUIs. To compete with Android GUIs, you often need to use Graphics View, which makes the .ui XML files less useful -- you need to define your UI layout in C++ code, which is inefficient. QML and Qt Quick and Qt Quick 1 aimed to make it easier to write GUIs for the Graphics View Framework. Qt Quick 2 provides superior performance than Qt Quick 1. It can do everything that Graphics View and Qt Quick 1 can do, so it replaces these technologies. However, it can't do everything that Widgets can do yet, so it doesn't replace Widgets yet. Nobody needs to abandon Qt Designer. New features are still being added to Qt Widgets (see http://qt-project.org/wiki/New-Features-in-Qt-5.2), and it will still be supported for many years. I still use it to create traditional office-style GUIs. However, when I want to make modern fluid GUIs, I use Qt Quick, because it is much more efficient for this purpose compared to Qt Widgets. On the topic of efficiency and animations, compare these 2 examples which do similar things: * http://developer.android.com/training/animation/cardflip.html * http://qt-project.org/doc/qt-5/qml-qtquick-flipable.html Files required: - Android: 6 XML files + 1 Java file - Qt Quick: 1 QML file Code required (excludes XML/comments/braces/empty lines) - Android: 34 lines of Java code - Qt Quick: 23 lines of QML code - (Also note: the average QML line is shorter than the average Java line) I think QML is for more efficient than Android's XML+Java to create a card flip effect. Finally, here is a Graphics View card-flipping example, which is also far less efficient than the QML example: https://blog.qt.digia.com/blog/2009/06/09/flippin-widgets-medium-rare-please/ Again, the bottom line is: * Choose the best tool currently available for the job. * Choose Qt Quick and QML for mobile phone apps. * Choose Qt Widgets and .ui XML files for traditional desktop office-style apps. Does this answer your question? Regards, Sze-Howe _______________________________________________ Development mailing list [email protected] http://lists.qt-project.org/mailman/listinfo/development
