Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Modern looking UI with QT

Tags:

qt

I have an wizard application written in C++/MFC that I want to improve the UI. Different buttons, change the dialog background color, etc. Could I use QT to improve the appearance or should I change to WPF and C#?

like image 872
Craig Avatar asked Sep 30 '13 22:09

Craig


People also ask

Is Qt good for UI?

Qt supports different development languages. C++ is efficient, powerful, and versatile. Qt's declarative UI language, QML, makes it easy to create UIs at blinding speed. You can even code in Python!

Is Qt used in industry?

Qt is used by tens of thousands of companies across 70+ industries and in all regions of the world. Qt is often used to target one or multiple of the following platforms: Desktop: Windows, Linux/X11 and Mac OS X.

Is Qt good for desktop application?

The attention of these corporations is certainly attracted by the mentioned above Qt Widgets, which is one of the most developed and advanced modules that allows you to create an efficient desktop application with little effort, making Qt one of the best cross-platform desktop frameworks.


1 Answers

Qt 5 gives you essentially five (5!) UI toolkits:

  1. The Gui module that is similar to what you got with a very good 2D graphics library in the late 1980s/early 1990s. You have access to the buffer of the window and to key/mouse events. Everything else is up to you. This would be the fastest way to port an existing application from "back then". The graphical primitives are neat, with fonts, painter paths, gradients, etc. but there's no notion of a widget, only of a top-level window. You draw everything where you want it to be within that window.

    The provided concepts are at a higher level of abstraction than typical platform toolkits like winapi or xlib. In terms of graphical primitives it is more akin in spirit to Cairo or PDF.

    It is possible to parallelize the painting of a QRasterWindow in the same way as it is done for QWidget.

  2. The Widgets module gives you Qt4-style widgets and layouts, with customize-able styles. This is the model perhaps most like MFC, although it has much more functionality. The widgets are so-called alien widgets - it means they don't have native window handles. This keeps things fast. You have a multitude of pre-written widgets to do user input/output of all kinds. It is possible to parallelize the painting of a widget..

  3. The Declarative module, a.k.a. Qt Quick 1, uses the QGraphicsView widget from the widgets module to display a graphical scene. This scene is described using QML. The controls are fairly rudimentary and there's no platform-specific styling. It will look all the same no matter where you run it. There is good support for animations/fluidity in the interface.

  4. The Quick module, a.k.a. Qt Quick 2, uses a new OpenGL ES-based scene graph and can run on top of either a widget from the widgets module, or a raw window from the gui module. The scene is described using QML. There is a desktop components set that gives you platform-styled controls like combo boxes, text inputs, tables, etc. The new scene graph can really leverage the hardware and will outperform both widgets and Qt Quick 1 when you have heavy animated UIs. This is the way to go for the future. Qt 5.2 brings in an entirely new Javascript engine and a new scene graph renderer, with even better performance. Qt 5.11 brings in a new Javascript engine again, twice as fast.

  5. The 3D module, exposed both via C++ and QML APIs, is a high-level 3D object and scene rendering system, tailored for interactive applications. It makes it easy to implement user interaction with 3D objects. The C++ and QML APIs are peers and can be used per your preference - this is in contrast to Qt Quick, where the only the QML API offers the full functionality.

Both Qt Quick 1 and Qt Quick 2 can wrap existing widgets at very modest performance cost, but you do lose out on some of the niceties of "native" QML objects.

Do note that there's a separation between the need for an OpenGL implementation and there being one provided on your system. On post-Windows-XP systems (Vista, 7, 8, etc.) you should normally use Qt 5 with its own ANGLE implementation of OpenGL ES 2 that runs on top of DirectX. Only on Windows XP you're forced to use the system OpenGL drivers.

Qt is a generally very nice framework to work with even for non-gui applications. It has good cross-platform abstractions of networking and file I/O, time/date, and provides a bunch of other general-purpose goodies. It is relatively easy to use it alongside ncurses, for example.

The fastest way to port existing MFC code would be to stay with C++ and use Qt with the qtwinmigrate solution. The latter is a BSD-licensed shim layer that can get you up and running very quickly.

like image 114
Kuba hasn't forgotten Monica Avatar answered Sep 23 '22 19:09

Kuba hasn't forgotten Monica