Documentation‎ > ‎Development‎ > ‎Getting Started‎ > ‎

Qt5 for beginners

Introduction


OctoMY™ is dependent on Qt5, and this section is here to give you a smooth start in case you are not already familiar with this wonderful platform.

Installing

I made this video earlier on how to isntall Qt:

Stability

Qt was first released in 1995 and has thus had a long time to stabilize. It has a huge set of regression tests that is run before every release and it is thoroughly tested on a bunch of compilers, platforms and devices.

Cross platform support

It is part of the core values for Qt to be platform agnostic. Qt supports the major desktop platforms, the major mobile platforms and a bunch of embedded hardware that you never heard of.  Please see the official list of community supported (free/open source) platforms here.

User interfaces

GUI code is Qt's forte. It has great tools for working with GUIs. It has an integrated graphical designer for the traditional C++ Widget UIs as well as a completely new set of graphical tools for working with QML/QtQuick based user interfaces.

Platform integration

Qt has wrapped all platform integration in a cross-platform way. This includes:
  • Launcher icons
  • Configuration file (with properly abstracted platform specifics like location and format)
  • Popups
  • Clipboard management
  • Drag and drop
  • Fullscreen/imersive mode switching.
  • Multiple display support
  • Tooltips
  • Platform look and feel
  • And much more
Basically Qt is Write once Run anywhere.

Containers & Strings

Qt has a bunch of stl-like container classes with extensions to accommodate Qt specific features. These classes include everything from Lists to maps to arrays and buffers.


Qt's string class is my favorite of any language. It has its quirks, but it gives you a ton of performance and features, and as usual its cross-platform together with all it's friends:

Timers, threads & events

The whole of Qt framework is implemented around an asynchronous architecture based on event-loops with light-weight events called "signals".

http://doc.qt.io/qt-5/qtqml-syntax-signals.html

Qt supports multiple levels of concurrency from low-level threads, through managed thread pools to modern map-reduce and "futures". It also has cross-platform high-performance locking mechanism such as mutecies, locks, wait conditions, lock free stuff, atomic operations and a whole bunch of other stuff that I didn't get a chance to check out yet.

http://doc.qt.io/qt-5/examples-threadandconcurrent.html

Of course Qt has support for timers that fit well into all this with a lot of convenience features such as adjusting the precision, triggering single-shot etc.

Input

Input from touch screens, mice and keyboards is handled using the event architecture, and Qt really has this wrapped up in a basket. Qt just recently (23/2-17) got official support for joysticks and gamepads.


There is also support for sensors like position, pressure, compass, rotation, temperature, so you can make never-ball clones too.


And there is support for blue-tooth for connecting and sharing game data over the air without access to wifi.


And there is camera support for whatever you might want to use that for in a game.


All cross-platform.

Utility classes

Where to start?
  • MD5/SHA other secure hash algorithms
  • Compression/decompression algorithms
  • Encryption/decryption algorithms
  • File handling both blocking, non-blocking, mapped etc.
  • File system handling such as copy, move, rename of files
  • File alteration monitoring
  • HTTP client
  • High performance socket programming
  • Synthetic UI events generation
  • Time and date
  • DNS access
  • Logging
  • Error messages
  • MIME and URL processing
  • json parser/generator
  • Gesture recognition
  • Compiled regex
  • Serial IO
  • XML parser/generator
  • SSL
  • Undo/Redo 
The list really goes on and on... See for your self here:

Internationalization

Out-of-the-box internationalization through the use of ICU with all the advanced features such as RTL support in text widgets etc.


Updates / plug-ins

Qt has a plug-in architecture. That means you can split your executable into bits and update them separately, reloading each bit dynamically at run-time.

Testing

Qt has it very own testing framework built right in. It supports exercising your code in all sorts of ways, including simulating of UI events. It also allos you to build comprehensive data-driven test suites with benchmarking capabilities.

Documentation

Qt has really good documentation, and it is continuously improving. If you clicked some of my links you would already know. Qt also has tools for creating and integrating documentation into your own projects, including a cross-platform help-file compiler.

Scripting

Qt has an embedded high-performance ECMA (a.k.a. java script) engine tied into its core. You also get a tightly embedded port of web-kit included as well, if you need it.


Media playback & encoding

Qt wraps g-streamer and other media libraries to support play back of media such as video and sound. It allows the developer to chose on which level they want to interact with media. On the high level you can just put a widget and run .play() on the low level you get access o buffers of video and audio for your processing pleasure.

Depending on the active back-end Qt also gives you access to encode streams to network/disk etc.


Performance graphics for 2D

In traditional Qt there exists different abstractions for graphics. For some smaller embedded platforms it can rely on a simple 2D subsystem only. But for most desktop platforms (Windows/MacOSX/Linux) and mobile platforms (Android/OSX) the 2D abstraction rests neatly on top of a high-performance 3D stack based on OpenGL or OpenGL ES respectively. 

This is a true gem, and makes graphics programming a joy thanks to the well thought out architecture that allows you to chose how high- or low- level you want to approach your graphics programming.

There are lots of classes that allow you to go about your drawing as usual with well known concepts like color, line thickness, and shape while knowing that it will all be 3D accelerated under the hood.



Then there is the whole new thing "QtQuick" or "QML". A declarative language that together with java script provides the quickest and meanest way to chug out interactive UI.

Performance graphics for 3D

Qt has traditionally had a very strong bond to OpenGL, and this bond has server Qt very well as OpenGL is portable and performant over a wide range of platforms. However with the realization that OpenGL is showing it's age, the ever present question of comparability with DirectX on the Microsoft platforms and the advent of new technologies like Vulkan lurking in the near future, Digia has made the wise strategic move of starting to pre-preemptively generalizing the hardware abstraction layer towards graphics hardware. So for now Qt is bound to OpenGL, but soon it will support many other graphics abstractions, to our great benefit.

While we wait, there is also nothing in Qt to hinder you from using DX together with Qt on the Microsoft platforms. Qt goes to great lengths to not interfere with other libraries on any platform, so it will work with a lot of other toolkits and engines, and you can even embed other graphics or game engines based on OpenGL inside Qt by exposing Qt's OpenGL context directly. Also keeping the same code-base for an application that is ported to the two noteworthy mobile platforms with Qt will be much simpler without DX.

Beyond all the convenience classes for managing OpenGL spesific features such as VBO, FBO, loading textures and shaders etc. there is also a great effort being made to provide a full-blown 3D engine in Qt. It is called Qt3D 2.0 and is a complete rewrite of the old Qt3D that was part of Qt4.x and that was part of only one release before it was removed due to political reasons (Nokia ditched Qt).

It has an impressive set of features and a lot of good thinking has gone into it's API to ensure that it can leverage the full potential of modern graphics hardware while staying flexible and performant. Another good news is that is in technology preview. This means that you can try it out today and it will be part of main-line Qt soon. You can read more about it here.

Math

As part of the 3D stack, Qt has a full set of performance math routines such as matrix, vector, quaternions, point, rect etc. The common stl math functions such as sqrt, floor, sin etc. are also wrapped in a platform-independence layer.


There are no support for advanced math like full blown physics engine, collision detection or response, but many popular engines exist that are fully compatible with Qt.

Assets management


Qt has a fully fledged resource management system that compiles resources into your binary. This is cross platform and supports any file type you need with special support for common image formats, svg, sounds, fonts, HTML, CSS. And loading and using resources is really simple since all of Qt's file handlign orutines accept URLs that point to these resources. Really awesome.

Further the new effort in Qt3D 2.0 adds assimp support so any assets supported by assimp will also automatically be compatible with Qt resource system.

2D Animation


Qt features a full framework for working with state machines. On top of this there sits a full framework for animating properties that can be used for making interactive UI in 2D (or even 3D if you play your cards right). It has all the stuff you expect like easing, automatic state transition and tons of convenience wrappers and ways of doing interesting stuff. It's like working with jQuery but in C++.




Comments