Modern looking UI with QT
Asked Answered
G

1

7

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#?

Genvieve answered 30/9, 2013 at 22:26 Comment(2)
Can you be a bit more specific as to what you want to do? Most of the changes should be doable using Qt's style sheets and themes. However you're looking at a rewrite of the UI portion either way to get away from MFC.Stumble
I need a grey background with a company bitmap on the top instead of the standard bitmap on the side for the wizard. Need to change the default BACK, NEXT, etc. buttons to custom looking with a black background and not 3-D looking. I am fine with rewriting the UI portion. Going to C# would be a lot more work as most of the heavy lifting is done in a DLL.Genvieve
P
17

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.

Prolong answered 30/9, 2013 at 23:9 Comment(3)
Wouldn't it be better lump Qt Quick 1 and 2 as 4. as they are quite same from application programmer perspective, and then have QGraphicsView alone as 3.?Conceptacle
@Conceptacle Qt Quick 1 and 2 are quite different. Qt Quick 1 works as long as widgets work. Qt Quick 2 uses a different QML engine and a different rendering engine. I don't know what percentage of Windows 7 machines it works on out of the box, but on a random mix of office Dells here, it has a 75% success rate before you fix the drivers (then it works on 100% of systems). That's like a big deal, wouldn't you say? :) The graphics/view framework maybe is worth a separate mention, that's true.Consecution
Well, that is a technical difference. Perhaps better distinction would be "raw" QML (be it version 1 or version 2) vs. using Qt Quick 2 Controls and other extra goodies, but I'm not expressing strong opinion about that one way or another. But QGV is quite clearly its own thing, very different from all the others (QGraphicsItem isn't even a QObject).Conceptacle

© 2022 - 2024 — McMap. All rights reserved.