RTXI v2.3 introduced many changes over the v1.4 release. Most of these changes should have a limited impact on your modules, but even in that case, you will need to make some edits to your code to port it to 2.3. This tutorial will focus on some common changes that should cover most use-cases. The changes mostly have to do with:

  1. Upgrading from Qt3 to Qt5
  2. Upgrading Qwt5 to Qwt6
  3. Changes to the DefaultGUIModel class

Upgrading from Qt3 to Qt5

Qt3 is an old version of the Qt library. It was released in 2001 and superceded by Qt4 in 2005 and Qt5 in 2012. The transition to Qt4 introduced many breaking changes to its API and classes, and it took a while to upgrade RTXI’s codebase to properly use it. We recommend that you look through the documentation Nokia provides on its website for porting from Qt3 to Qt4: http://doc.qt.io/qt-4.8/porting4.html.

RTXI 2.1 upgraded the UI framework from Qt4 to Qt5. This introduces some changes, though not nearly as many as introduced by the Qt4 transition. A changelog and upgrade info is provided on the Qt website: https://wiki.qt.io/Transition_from_Qt_4.x_to_Qt5

Porting Modules that Abstract from DefaultGUIModel

For v2.3, the code exposed to users has been simplified and the customizability enhanced. The most significant change is in the createGUI function and how the UI is generated. There are also some simple changes that correspond to syntax and class name changes in Qt4. They are as follows:

1. Change #includes
Libraries for Qt5 are included differently. To include them directly, change the names as indicated in the Qt5 documentation. For example, <qpushbutton.h> becomes <QPushButton>. Look through the Qt5 documentation to see what the name changes are. Another, simpler option is to just remove all the q* includes and replace them with <QtWidgets>. QtWidgets will make Qt pull in all the libraries needed to compile whatever Qt classes are present in the code without the need to specify them directly.

Essentially, something like:

#include <main_window.h>
#include <qgridview.h>
#include <qhbox.h>
#include <qhbuttongroup.h>
#include <qlabel.h>
#include <qlayout.h>
#include <qpushbutton.h>
#include <qtimer.h>
#include <qtooltip.h>
#include <qvalidator.h>
#include <qvbox.h>
#include <qwhatsthis.h>
#include <main_window.h>
#include <QtWidgets>

2. Change QWhatsThis
This call is made by default in the constructors of module classes that abstract from DefaultGUIModel. Change:

QWhatsThis::add(this, "text");

3. Add a resize timer
At the end of the constructor, after the module has been built and the refresh function has been called, add the line:

QTimer::singleShot(0, this, SLOT(resizeMe()));

4. Switch to createGUI + customizeGUI API
In v1.4, the GUI is created using DefaultGUIModel’s createGUI function. If you wanted to add any custom elements, you had to overload the function and copy/paste the code in the default_gui_model.cpp and then add your own stuff. That’s changed now.

You no longer should overload the createGUI function. Now, just call DefaultGUIModel’s createGUI function and then call a new function, customizeGUI, to, well, customize it.

Define customizeGUI within the modules you are building. Call it after createGUI returns. To use customizeGUI properly, you need to do:

  1. Grab the module layout object created by createGUI:

    QGridLayout *customLayout = DefaultGUIModel::getLayout();
  2. Add custom elements to the layout. For more explanation about this, see the example customizeGUI function defined in the plugin template.

  3. Set the edited layout.


5. Enforce types for get/set methods on RTXI workspace variables
RTXI workspace variables are displayed in the UI as QStrings, and within the code they are regularly converted to the native types they are supposed to represent in memory, such as int, double, and string. 2.3 should take the calls in v1.4 without issue, but if you run into problems, check the types of the variables you are using.

Note: v2.3 does not support strings for PARAMETER variables. Use the COMMENT type instead.