khajvah
khajvah

Reputation: 5090

UI with C++ vs with XML vs with QML

When I create a project, it comes with *.ui file which is an XML kind of file, I am only creating UI with pure C++ (classes). I have heard there is another way of creating UIs, with QML.

What are the pros and cons of each UI creating way?

Upvotes: 11

Views: 6466

Answers (2)

SirDarius
SirDarius

Reputation: 42879

Don't forget that you can also embed a QtWebkit view and use HTML directly as the user interface controls.

From Qt Documentation — User Interfaces — Comparison of UI Interfaces:

Comparison of UI Interfaces

The following table compares Qt Widgets and Qt Quick interfaces.

Qt Quick / Qt Quick Controls Qt Widgets Comments
Used language(s) QML/JS C++
Native look and feel ✔️ ✔️ Qt Widgets and Qt Quick Controls support native look and feel on their target platforms.
Custom styling ✔️ ✔️ Qt Widgets provide customization with style sheets and Qt Quick Controls has a selection of >customizable styles.
Fluid animated UIs ✔️ Qt Widgets do not scale well for animations. Qt Quick offers a convenient and natural way to >implement animations in a declarative manner.
Touch screen ✔️ Qt Widgets often require a mouse cursor for good interaction, whereas Qt Quick provides QML types >for touch interaction.
Standard industry widgets ✔️ ✔️ Qt Widgets provide all the bells and whistles, developed over two decades, needed >for building standard industry type applications.
Model/View programming ✔️ ✔️ Qt Quick provides convenient views, but Qt Widgets provide more convenient and complete >framework. In addition to Qt Quick views, Qt Quick Controls provide a TableView.
Rapid UI development ✔️ ✔️ Qt Quick is an excellent choice for rapid UI prototyping and development.
HW accelerated graphics ✔️ ✔️ Qt provides full hardware acceleration for Qt Quick interfaces and Qt Widgets >interfaces are rendered in software. The Graphics overview has more information.
Graphical effects ✔️ Several Qt Quick modules provide graphical effects and Qt Widgets interfaces can use Qt GUI >for effects.
Rich text processing ✔️ ✔️ Qt Widgets currently provide the most comprehensive base for implementing text editors. >Qt's rich text document classes can also be utilized in Qt Quick and Qt Quick Controls' TextArea, but may require >some C++ implementation.

Upvotes: 8

Clifford
Clifford

Reputation: 93456

The .ui file is generated for/by "visual" design layout tools such as QtDesigner - I would not suggest you generate or edit them by hand; if you choose not to use "visual" or "RAD" GUI design tools then programmatically instantiating widgets in C++ is probably fine.

Upvotes: 4

Related Questions