SlideShare a Scribd company logo
1 of 57
Download to read offline
© Integrated Computer Solutions, Inc. All Rights Reserved
Porting Motif
Applications to Qt
Jeff Tranter <jtranter@ics.com>
Integrated Computer Solutions, Inc.
© Integrated Computer Solutions, Inc. All Rights Reserved
Agenda
• Introduction
• Anatomy of an Application
• Toolkit Comparison
• Development Environment
• Inter-client Communication
• Automation: GUI builders
• I18N, Session Management and Help
• Extras
• Porting Your Application
• Getting Help
• References
• Q&A
© Integrated Computer Solutions, Inc. All Rights Reserved
Introduction
• Despite its age, many legacy Motif applications still in production.
• A number of advantages to migrating to newer platforms.
• Porting to Qt framework can achieve many of the benefits without
requiring a total rewrite.
• Will look at scenarios, strategies, and advice for porting Motif
applications to Qt.
• ICS has done many Motif to Qt conversions and you can benefit
from our real-world experience.
© Integrated Computer Solutions, Inc. All Rights Reserved
What is Motif?
• GUI toolkit for graphical desktop applications.
• Emerged in the 1980s on UNIX workstations.
• C based, uses X Windowing System.
• Often used for high-end complex applications in domains like
finance, engineering, RADAR, air traffic control, military.
• Was commercial; made free for open source platforms (e.g.
Linux) in 2000; released under LGPL in 2012.
• Still some minimal maintenance being done, latest release 2.3.6
in 2016.
© Integrated Computer Solutions, Inc. All Rights Reserved
What is Qt?
• Cross-platform application (not just GUI) framework.
• C++ based.
• Supports desktop, mobile, embedded platforms.
• Commercial and open source (LGPL) licensing.
© Integrated Computer Solutions, Inc. All Rights Reserved
Reasons for Porting to Qt
• Main incentive usually cross-platform or additional platform
support (e.g. Windows, Mac).
• Improve UX: color depth, higher-quality fonts, visual effects,
native look and feel, localization.
• Want to add new features that are difficult with Motif or want to
leverage features of Qt (e.g. web view).
• Desire to move from C to cleaner, type-safe, object-oriented code
in C++.
• Need a toolkit with professional support, bug fixes and frequent
releases.
© Integrated Computer Solutions, Inc. All Rights Reserved
Reasons to Rewrite Rather Than
Port
• Moving to mobile, tablet, or embedded touchscreen platforms
may require entirely new UX design.
• May be moving to a platform that does not support Qt or C++.
• May have decided to use native APIs on the new platform.
• Current system is not maintainable, documented, understood or
missing source code.
• Want to entirely re-architect system.
© Integrated Computer Solutions, Inc. All Rights Reserved
Evaluating Your Application
Effort and cost to port can vary depending on a number of factors:
• Complexity of the existing application.
• Hardware dependencies.
• Available time and resources.
• User expectations.
• Handwritten GUI code vs. builder-generated UI code.
• Use of third party or custom widgets or other third party code or
libraries.
© Integrated Computer Solutions, Inc. All Rights Reserved
Evaluating Your Application
• Understanding of existing design and code.
• Hidden/undocumented features or behavior.
• Existing unit and regression tests.
• Documentation.
• Your team's knowledge of Qt.
• Commercial or open source version of Qt.
© Integrated Computer Solutions, Inc. All Rights Reserved
Anatomy of an Application
• At a high level, both Motif and Qt:
●
are event-driven.
●
have similar basic widgets with hierarchical parent-child
relationships.
• Motif uses callbacks, Qt uses more sophisticated and safer
signals and slots.
• Qt separates widgets from layout managers.
© Integrated Computer Solutions, Inc. All Rights Reserved
Toolkit Comparison
Description Motif Qt
Initialize XtAppInitialize() QApplication()
Create Widgets XmCreateWidgetName() QWidgetName()
Event Response XtAddCallback() QObject::connect()
Show Widget XtRealizeWidget() QWidget::show()
Enter Event Loop XtAppMainLoop() QApplication::exec()
© Integrated Computer Solutions, Inc. All Rights Reserved
Hello Motif - Simple Motif Program
With Callbacks
#include <Xm/Xm.h>
#include <Xm/MainW.h>
#include <Xm/ToggleB.h>
#include <stdio.h>
#include <stdbool.h>
void toggleChangedCB(
Widget tb,
XtPointer client_data,
XtPointer call_data)
{
XmToggleButtonCallbackStruct *tbInfo = (XmToggleButtonCallbackStruct *)call_data;
printf("The button state is: %sn", tbInfo->set == XmSET ? "ON" : "OFF");
printf("The app data is: %ldn", (long) client_data);
}
...
© Integrated Computer Solutions, Inc. All Rights Reserved
Hello Motif - Simple Motif Program
With Callbacks
int main(int argc, char **argv)
{
Widget topLevel, mainW, tb;
XtAppContext app;
topLevel = XtVaOpenApplication(&app, "Example", NULL, 0, &argc, argv, NULL,
sessionShellWidgetClass, NULL);
mainW = XmCreateMainWindow(topLevel, "main_w", NULL, 0);
tb = XmCreateToggleButton(mainW, "Hello Motif", NULL, 0);
XtAddCallback(tb, XmNvalueChangedCallback, toggleChangedCB, (XtPointer) 42);
XtManageChild(tb);
XtManageChild(mainW);
XtRealizeWidget(topLevel);
XtAppMainLoop(app);
return 0;
}
© Integrated Computer Solutions, Inc. All Rights Reserved
Hello Motif - Simple Motif Program
With Callbacks
© Integrated Computer Solutions, Inc. All Rights Reserved
Hello Qt – Simple Qt Program with
Signals and Slots
// qtexample.h
#include <QObject>
class SomeObj : public QObject
{
Q_OBJECT
public:
SomeObj(int objData) : QObject(nullptr), _objData(objData) {};
public slots:
void toggled(bool toggleVal);
protected:
int _objData;
};
© Integrated Computer Solutions, Inc. All Rights Reserved
Hello Qt – Simple Qt Program with
Signals and Slots
// qtexample.cpp
#include <QtWidgets/QApplication>
#include <QtWidgets/QPushButton>
#include <QObject>
#include <iostream>
#include "qtexample.h"
void SomeObj::toggled(bool toggleVal)
{
std::cerr << "The button state is: " << toggleVal << std::endl;
std::cerr << "The app data is: " << _objData << std::endl;
}
...
© Integrated Computer Solutions, Inc. All Rights Reserved
Hello Qt – Simple Qt Program with
Signals and Slots
int main(int argc, char ** argv)
{
QApplication app(argc, argv);
QPushButton tb("Hello Qt");
tb.setCheckable(true);
tb.setChecked(true);
tb.show();
SomeObj myObject(42);
QObject::connect(&tb, &QPushButton::toggled, &myObject, &SomeObj::toggled);
return app.exec();
}
© Integrated Computer Solutions, Inc. All Rights Reserved
Hello Qt – Simple Qt Program with
Signals and Slots
© Integrated Computer Solutions, Inc. All Rights Reserved
Toolkit Comparison – Common UI
Objects
Functionality Motif Qt Major Differences
Text/Pixmap Label XmLabel QLabel QLabel can also display rich text or a movie.
PushButton, ToggleButton XmPushButton,
XmToggleButton
QPushButton Same class offers both kinds of functionality.
Otherwise similar.
RadioButton, CheckBox XmToggleButton,
XmRowColumn
QCheckBox, QRadioButton,
QButtonGroup
In Motif, the parent RowColumn's resources dictate
behavior.
Scrollbar XmScrollBar QScrollBar Very similar.
Scale XmScale QSlider Very similar.
List of items XmList, XmContainer QListView QListView can do multicolumn, hierarchical lists of
arbitrary type. Motif XmList is limited to single
column, linear list of XmStrings, but XMContainer is
as powerful.
Single Line Text Field XmTextField QLineEdit QLineEdit supports rich text, encrypted entry,
validator & built-in undo/redo.
Text XmText QTextEdit Same as above. Also QPlainTextEdit for plain text.
Horiz/Vert Tiled Windows XmPanedWindow QSplitter Very similar.
SpinBox XmSpinBox QSpinBox Very similar.
© Integrated Computer Solutions, Inc. All Rights Reserved
Toolkit Comparison – Menus and
Options
Functionality Motif Qt Major Differences
Horizontal Menubar XmMenuBar QMenuBar QMenuBar has several
insertItem methods.
Pulldown Menu XmPulldownMenu QMenu Qt provides a cleaner
abstraction using QMenu as
the common object for
pulldowns and popups.Popup Menu XmCreatePopupMenu QMenu
Option Menu, Combo
Box
XmComboBox,
XmOptionMenu
QComboBox Qt uses QComboBox for both.
© Integrated Computer Solutions, Inc. All Rights Reserved
Toolkit Comparison - Dialogs
Functionality Motif Qt
Error XmCreateErrorDialog QErrorMessage
Information XmCreateInformationDialog QMessageBox
Question XmCreateQuestionDialog QMessageBox
Warning XmCreateWarningDialog QMessageBox
Progress XmCreateWorkingDialog QProgressDialog
Simple Input XmCreatePromptDialog QInputDialog
File Chooser XmCreateFileDialog QFileDialog
Item Chooser XmCreateSelectionDialog Use QListWidget or QListView
Command History XmCreateCommand Use QListWidget or QListView
Generic/Custom XmCreateMessageDialog QDialog
© Integrated Computer Solutions, Inc. All Rights Reserved
Toolkit Comparison – Complex
Widgets
• Main Window
• OpenGL
• Table
• MDI
• Tab Widget
• GraphicsView
• Frame
© Integrated Computer Solutions, Inc. All Rights Reserved
Toolkit Comparison - Complex
Widgets
• QDial
• QLCDNumber
• QDateTimeEdit
• QToolBox
• QToolBar, QToolButton
• QDockWidget
• QSplashScreen
• QSvgWidget, QSvgRenderer, QSvgGenerator
© Integrated Computer Solutions, Inc. All Rights Reserved
Layout Management
• XmBulletinBoard
• XmScrolledWindow: QAbstractScrollArea, QScrollArea
• XmRowColumn: QHBoxLayout, QVBoxLayout, QGridLayout
• XmPanedWindow: QSplitter
• XmFrame: QGroupBox (not QFrame)
• XmRadioBox: QButtonGroup, QRadioButton
• XmForm: implement using Qt's layout management
© Integrated Computer Solutions, Inc. All Rights Reserved
Layout Management
Tips for layout management troubleshooting:
• Use Qt Designer.
• Use simple QWidgets with bright background colors or labels for
all widgets in a layout.
• May have to subclass certain widgets to override the sizeHint and
minimumSizeHint values to be able to resize them properly.
© Integrated Computer Solutions, Inc. All Rights Reserved
Event Handling - Overview
• Motif: At the basic level, each widget instance contains a
translation table that maps events to procedure names. Another
table, the action table, maps procedure names to actual
procedures. When an event gets dispatched to a widget, the
corresponding action procedure is invoked.
• In Qt, events are delivered to objects derived from the base
QObject class using the QObject::event interface.
© Integrated Computer Solutions, Inc. All Rights Reserved
Event Handling – Do Nothing
• In Motif, widget instances “inherit” built-in event handlers that
take care of the basic behavior (for example, pressing the
backspace key in a text widget erases a character).
• In Qt, the C++ inheritance model takes care of the default
behavior of widget instances/subclasses.
© Integrated Computer Solutions, Inc. All Rights Reserved
Event Handling – Behavioral Events
• Motif: programmer can add procedures for certain combinations
of events.
• Example: XmPushButton callbacks called when user presses and
releases active mouse button inside the widget.
• Qt has signals and slots.
• Signal emitted when an event occurs.
• Slot is a method called in response to a signal.
• Signal from an object can be connected to a slot in any other
object as long as type signature is compatible.
© Integrated Computer Solutions, Inc. All Rights Reserved
Event Handing – Finer Control
• Motif: For finer control over event handling, the translation tables
and actions procedures can be changed or added to Motif
widgets.
• Qt: Additional signals can be easily added in sub-classed Qt
widgets.
© Integrated Computer Solutions, Inc. All Rights Reserved
Event Handling – Direct Dispatch
• Motif: Application can register event handler procedures with the
Xt event dispatcher for a particular widget. Procedures are called
before the ones in the translation table.
• Qt: QObject::event virtual method can be overridden to bypass or
to add event handling for a widget.
• Most Qt widgets have several event handling methods that are at
a higher level of abstraction and can be overridden without
completely changing the behavior of a widget through the lower
level QObject::event method.
• Qt widget can observe another widget’s events using the
QObject::eventFilter, QObject::installEventFilter methods.
© Integrated Computer Solutions, Inc. All Rights Reserved
Event Handling – More Control
• Some applications also grab the keyboard, pointer, or the entire
server for specialized event handling. It is also possible to go
down to the level of X11 to peek at, extract, resend events from
the event queue.
• In Qt, more control can be exercised using the available methods
on the main application object to manipulate the event loop or by
installing an application-wide event filter. Creation and dispatch
of custom and non-GUI events is also possible.
© Integrated Computer Solutions, Inc. All Rights Reserved
Look and Feel
• Motif has a unique look and feel.
• Qt has some built-in styles that generally look native on the
platform.
• Support for CSS-like stylesheets, style plugins, or custom widgets.
© Integrated Computer Solutions, Inc. All Rights Reserved
Development Environment –
Language, Compilers, Libraries
• Need to develop at least some of your application in C++.
• Can call existing C code if desired, or wrap it in C++ classes.
• May need to port legacy code to build with modern compilers.
• IDEs: Qt Creator, Visual Studio, vi/emacs...
• Build system: qmake, cmake.
• Dependencies on third-party libraries.
© Integrated Computer Solutions, Inc. All Rights Reserved
Dev. Environment – Distribution,
Installation, Documentation
• Qt available under open source and commercial license options.
• Generally not hard to comply with license requirements.
• Typically will want to ship Qt with your application.
• Qt renowned for quality of developer documentation.
• Doxygen tool for documenting your code, especially libraries.
• May want install wizard on Windows, dmg on Mac OS, deb/rpm on
Linux.
© Integrated Computer Solutions, Inc. All Rights Reserved
Inter-client Communication –
Selection and Clipboard
• X Windows supports Primary selection and Clipboard selection.
• Primary selection enables availability of data as soon as selected.
• Clipboard provides more traditional support by making data
available explicitly using copy or cut operation.
• Qt has built-in support for both using the QClipboard class.
© Integrated Computer Solutions, Inc. All Rights Reserved
Inter-client Communication – Drag
and Drop
• Drag and Drop can be used to transfer data within and between
applications.
• Motif’s support of drag and drop implemented on top of the
selection mechanisms provided by Xt and the X ICCCM.
• Under X11, Drag and Drop support in Qt based on the XDND
protocol.
• Relevant Qt classes: QDrag, QDragEnterEvent, QDragLeaveEvent,
QDragMoveEvent, QDropEvent
© Integrated Computer Solutions, Inc. All Rights Reserved
Automation – GUI Builder
• Qt provides Qt Designer GUI builder.
• Allows laying out windows, widgets, dialogs and other elements.
• Can set properties and connect signals and slots.
• Saved as XML, which is then used to generate C++ code using
uic.
• Generally considered best practice to use it.
© Integrated Computer Solutions, Inc. All Rights Reserved
Scripting
• Qt provides support for application scripting with ECMAScript
(JavaScript).
• See QScriptEngine and related classes
• Considered deprecated for new applications. Instead use
QJSEngine class which is part of QML.
• Also support for JavaScript in browser via QtWebEngine.
• Qt applications can also be written entirely in Python using PyQt
or PySide bindings.
© Integrated Computer Solutions, Inc. All Rights Reserved
Testing and Inspection
• Qt provides Qt Test module, a framework for unit testing.
• Can also use Google Test, etc. with Qt.
• For automated, functional, scripting GUI record/playback testing,
recommend commercial SQUISH tool.
• Various debug and analysis tools, some available from Qt Creator
and some external (e.g. Gamma Ray).
© Integrated Computer Solutions, Inc. All Rights Reserved
Localization and
Internationalization
• QString: uses Unicode.
• QObject::tr(): For translating user visible strings.
• Translations looked up at run time from a catalog.
• Tools:
●
lupdate: Extracts translatable strings from source files.
●
Linguist: Application for translators to enter translations.
●
lrelease: Creates compact binary table used at run time.
• Support for various languages using Qt's text engine for all input
(QTextEdit, QLineEdit) and display (QLabel) controls.
• Support for localized formats for numbers, times, timezones,
dates, currency, etc.
© Integrated Computer Solutions, Inc. All Rights Reserved
Session Management
• Often a requirement for applications to save settings or state.
• X11 applications can register with X Session Manager.
• Supported in Qt by QSessionManager class.
• More common just to save settings using QSettings class.
© Integrated Computer Solutions, Inc. All Rights Reserved
Help
• Limited support in Motif for application help (callback for context
sensitive help and tooltip resource).
• Qt provides tooltips when hovering over a widget, What's This?
help, status bar.
• Applications can use Qt's hypertext help system used by
Assistant (QHelpEngine and related classes).
• Could also implement HTML-based help in a web view.
© Integrated Computer Solutions, Inc. All Rights Reserved
Extras
• Unlike Motif, Qt is much more than a GUI toolkit.
• Support for:
●
I/O, networking
●
Images
●
XML
●
Date/time
●
SQL databases
●
Strings, containers
●
Model/View pattern
●
Threading
●
Resource system
© Integrated Computer Solutions, Inc. All Rights Reserved
Porting Your Application
• Recommend to start with small non-mission critical application to
port first.
• Learn, gain experience, add more features.
• Gain experience, and then move on to larger applications next.
© Integrated Computer Solutions, Inc. All Rights Reserved
Port or Redesign?
• Porting effort can have large impact on architecture for complex
applications.
• May want to re-architect.
• Opportunity to modernize.
• More object-oriented design.
• Model/View architecture to separate visual design from data.
© Integrated Computer Solutions, Inc. All Rights Reserved
Gradual Migration
• Qt Motif Extension allowed running Motif widgets in a Qt
application.
• Was dropped in Qt 4, but still works with a few code changes.
• Porting to Qt 5 difficult as Qt now uses xcb and not xlib.
© Integrated Computer Solutions, Inc. All Rights Reserved
Porting Strategies for Applications
• Will look at some different porting strategies.
• Often initial port stays on Linux/UNIX, then later moves to other
platforms.
© Integrated Computer Solutions, Inc. All Rights Reserved
Porting Strategies – Hand Written
GUI
• Dynamic layout of widgets.
• Custom layout or constraints.
• Hard to implement using GUI builder.
• Typically can do this with Qt's layout engine.
© Integrated Computer Solutions, Inc. All Rights Reserved
Porting Strategies – GUI Builder
Generated
• e.g. using Builder Xcessory (BX Pro) GUI builder tool on Motif.
• Typically convert to Qt Designer.
• Automated conversion possible in theory.
© Integrated Computer Solutions, Inc. All Rights Reserved
Porting Strategies – C Based
• Need to port some or all of your code to C++.
• Your team may need to learn object-oriented design.
• Maybe require re-architecting (e.g. to separate GUI from business
logic).
© Integrated Computer Solutions, Inc. All Rights Reserved
Porting Strategies – Graphics Heavy
• Qt port can be opportunity to better leverage modern graphics
hardware.
• Many facilities available in Qt (QPainter, QGraphicsView,
OpenGL).
• OpenGL code can be ported quite easily.
• X11 painting code straightforward to port to Qt's painter API.
© Integrated Computer Solutions, Inc. All Rights Reserved
Porting Strategies – Custom
Widgets
• Custom widgets in Motif are very complex, typically 10K-20K LOC.
• Much easier with Qt, subclass existing widget or QWidget.
• Qt custom widgets have properties with setters and getters, can
be used with Designer.
• Don't have to implement layout management in the widget.
© Integrated Computer Solutions, Inc. All Rights Reserved
Porting Strategies – Custom
Widgets
Description Motif Qt
Initialize ClassInitialize, Initialize, Create widget constructor(s)
Re-render the widget Redisplay update(), repaint()
Draw the widget DrawVisual, DrawShadow paintEvent, QPainter
Optimal widget size WidgetSize, VisualSize sizeHint
Accommodate widget Resize adjustSize
Changes in resource setValues public set/get methods
Event handling Callbacks/actions/translations events, signals & slots
Geometry management geometry_manager QLayout
Event propagation parent_process automatic, event filter
© Integrated Computer Solutions, Inc. All Rights Reserved
Getting Help
• Porting can be a significant effort.
• Can also involve re-architecting application.
• Consider bringing in outside consultants for:
●
assistance (staff augmentation).
●
turnkey porting.
●
training, mentoring.
●
UX design.
© Integrated Computer Solutions, Inc. All Rights Reserved
References
1. Qt website, https://www.qt.io/
2. ICS Motif website, http://motif.ics.com/
3. Porting X/Motif Applications to Qt, Scenarios and Advice for a Smooth
Migration, ICS whitepaper,
https://motif.ics.com/sites/default/files/porting_motif_to_qt.pdf
© Integrated Computer Solutions, Inc. All Rights Reserved
Questions and Answers
© Integrated Computer Solutions, Inc. All Rights Reserved
Porting Motif
Applications to Qt
Jeff Tranter <jtranter@ics.com>
Integrated Computer Solutions, Inc.

More Related Content

What's hot

Creating Advanced GUIs for Low-power MCUs with Qt
Creating Advanced GUIs for Low-power MCUs with QtCreating Advanced GUIs for Low-power MCUs with Qt
Creating Advanced GUIs for Low-power MCUs with QtICS
 
Qt test framework
Qt test frameworkQt test framework
Qt test frameworkICS
 
Introduction to the Qt State Machine Framework using Qt 6
Introduction to the Qt State Machine Framework using Qt 6Introduction to the Qt State Machine Framework using Qt 6
Introduction to the Qt State Machine Framework using Qt 6ICS
 
Building Web Apps Sanely - EclipseCon 2010
Building Web Apps Sanely - EclipseCon 2010Building Web Apps Sanely - EclipseCon 2010
Building Web Apps Sanely - EclipseCon 2010Chris Ramsdale
 
Google Developer Fest 2010
Google Developer Fest 2010Google Developer Fest 2010
Google Developer Fest 2010Chris Ramsdale
 
Practical Multi-language Generative Programming
Practical Multi-language Generative ProgrammingPractical Multi-language Generative Programming
Practical Multi-language Generative ProgrammingSchalk Cronjé
 
Practical C++ Generative Programming
Practical C++ Generative ProgrammingPractical C++ Generative Programming
Practical C++ Generative ProgrammingSchalk Cronjé
 
Integr8tor v2019.07 release notes
Integr8tor v2019.07 release notesIntegr8tor v2019.07 release notes
Integr8tor v2019.07 release notesucamco
 
AGDK tutorial step by step
AGDK tutorial step by stepAGDK tutorial step by step
AGDK tutorial step by stepJungsoo Nam
 
Generative Programming In The Large - Applied C++ meta-programming
Generative Programming In The Large - Applied C++ meta-programmingGenerative Programming In The Large - Applied C++ meta-programming
Generative Programming In The Large - Applied C++ meta-programmingSchalk Cronjé
 
VMworld 2013: On the Way to GPU Virtualization – 3D Acceleration in Virtual M...
VMworld 2013: On the Way to GPU Virtualization – 3D Acceleration in Virtual M...VMworld 2013: On the Way to GPU Virtualization – 3D Acceleration in Virtual M...
VMworld 2013: On the Way to GPU Virtualization – 3D Acceleration in Virtual M...VMworld
 
Android executable modeling: beyond android programming
Android executable modeling: beyond android programmingAndroid executable modeling: beyond android programming
Android executable modeling: beyond android programmingOlivier Le Goaër
 

What's hot (13)

Creating Advanced GUIs for Low-power MCUs with Qt
Creating Advanced GUIs for Low-power MCUs with QtCreating Advanced GUIs for Low-power MCUs with Qt
Creating Advanced GUIs for Low-power MCUs with Qt
 
Qt test framework
Qt test frameworkQt test framework
Qt test framework
 
Introduction to the Qt State Machine Framework using Qt 6
Introduction to the Qt State Machine Framework using Qt 6Introduction to the Qt State Machine Framework using Qt 6
Introduction to the Qt State Machine Framework using Qt 6
 
Building Web Apps Sanely - EclipseCon 2010
Building Web Apps Sanely - EclipseCon 2010Building Web Apps Sanely - EclipseCon 2010
Building Web Apps Sanely - EclipseCon 2010
 
Google Developer Fest 2010
Google Developer Fest 2010Google Developer Fest 2010
Google Developer Fest 2010
 
JBoss World 2010
JBoss World 2010JBoss World 2010
JBoss World 2010
 
Practical Multi-language Generative Programming
Practical Multi-language Generative ProgrammingPractical Multi-language Generative Programming
Practical Multi-language Generative Programming
 
Practical C++ Generative Programming
Practical C++ Generative ProgrammingPractical C++ Generative Programming
Practical C++ Generative Programming
 
Integr8tor v2019.07 release notes
Integr8tor v2019.07 release notesIntegr8tor v2019.07 release notes
Integr8tor v2019.07 release notes
 
AGDK tutorial step by step
AGDK tutorial step by stepAGDK tutorial step by step
AGDK tutorial step by step
 
Generative Programming In The Large - Applied C++ meta-programming
Generative Programming In The Large - Applied C++ meta-programmingGenerative Programming In The Large - Applied C++ meta-programming
Generative Programming In The Large - Applied C++ meta-programming
 
VMworld 2013: On the Way to GPU Virtualization – 3D Acceleration in Virtual M...
VMworld 2013: On the Way to GPU Virtualization – 3D Acceleration in Virtual M...VMworld 2013: On the Way to GPU Virtualization – 3D Acceleration in Virtual M...
VMworld 2013: On the Way to GPU Virtualization – 3D Acceleration in Virtual M...
 
Android executable modeling: beyond android programming
Android executable modeling: beyond android programmingAndroid executable modeling: beyond android programming
Android executable modeling: beyond android programming
 

Similar to Porting Motif Applications to Qt

Developing and Benchmarking Qt applications on Hawkboard with Xgxperf
Developing and Benchmarking Qt applications on Hawkboard with XgxperfDeveloping and Benchmarking Qt applications on Hawkboard with Xgxperf
Developing and Benchmarking Qt applications on Hawkboard with XgxperfPrabindh Sundareson
 
Best Practices in Qt Quick/QML - Part 1 of 4
Best Practices in Qt Quick/QML - Part 1 of 4Best Practices in Qt Quick/QML - Part 1 of 4
Best Practices in Qt Quick/QML - Part 1 of 4ICS
 
Qt Automotive Suite - under the hood // Qt World Summit 2017
Qt Automotive Suite - under the hood // Qt World Summit 2017Qt Automotive Suite - under the hood // Qt World Summit 2017
Qt Automotive Suite - under the hood // Qt World Summit 2017Johan Thelin
 
Qt for Python
Qt for PythonQt for Python
Qt for PythonICS
 
Migrating from Photon to Qt
Migrating from Photon to QtMigrating from Photon to Qt
Migrating from Photon to QtICS
 
Migrating from Photon to Qt
Migrating from Photon to QtMigrating from Photon to Qt
Migrating from Photon to QtJanel Heilbrunn
 
Qt for beginners part 1 overview and key concepts
Qt for beginners part 1   overview and key conceptsQt for beginners part 1   overview and key concepts
Qt for beginners part 1 overview and key conceptsICS
 
PyQt Application Development On Maemo
PyQt Application Development On MaemoPyQt Application Development On Maemo
PyQt Application Development On Maemoachipa
 
Best Practices in Qt Quick/QML - Part 3
Best Practices in Qt Quick/QML - Part 3Best Practices in Qt Quick/QML - Part 3
Best Practices in Qt Quick/QML - Part 3ICS
 
So I downloaded Qt, Now What?
So I downloaded Qt, Now What?So I downloaded Qt, Now What?
So I downloaded Qt, Now What?ICS
 
Plasmaquick Workshop - FISL 13
Plasmaquick Workshop - FISL 13Plasmaquick Workshop - FISL 13
Plasmaquick Workshop - FISL 13Daker Fernandes
 
CMake: Improving Software Quality and Process
CMake: Improving Software Quality and ProcessCMake: Improving Software Quality and Process
CMake: Improving Software Quality and ProcessMarcus Hanwell
 
Necessitas - Qt on Android - from FSCONS 2011
Necessitas - Qt on Android - from FSCONS 2011Necessitas - Qt on Android - from FSCONS 2011
Necessitas - Qt on Android - from FSCONS 2011Johan Thelin
 
Building Cross-Platform Apps using Qt and Qyoto
Building Cross-Platform Apps using Qt and QyotoBuilding Cross-Platform Apps using Qt and Qyoto
Building Cross-Platform Apps using Qt and QyotoJeff Alstadt
 
Hybrid and Multi-Cloud Strategies for Kubernetes with GitOps
Hybrid and Multi-Cloud Strategies for Kubernetes with GitOpsHybrid and Multi-Cloud Strategies for Kubernetes with GitOps
Hybrid and Multi-Cloud Strategies for Kubernetes with GitOpsWeaveworks
 
Hybrid and Multi-Cloud Strategies for Kubernetes with GitOps
Hybrid and Multi-Cloud Strategies for Kubernetes with GitOpsHybrid and Multi-Cloud Strategies for Kubernetes with GitOps
Hybrid and Multi-Cloud Strategies for Kubernetes with GitOpsSonja Schweigert
 

Similar to Porting Motif Applications to Qt (20)

Developing and Benchmarking Qt applications on Hawkboard with Xgxperf
Developing and Benchmarking Qt applications on Hawkboard with XgxperfDeveloping and Benchmarking Qt applications on Hawkboard with Xgxperf
Developing and Benchmarking Qt applications on Hawkboard with Xgxperf
 
Best Practices in Qt Quick/QML - Part 1 of 4
Best Practices in Qt Quick/QML - Part 1 of 4Best Practices in Qt Quick/QML - Part 1 of 4
Best Practices in Qt Quick/QML - Part 1 of 4
 
Qt Automotive Suite - under the hood // Qt World Summit 2017
Qt Automotive Suite - under the hood // Qt World Summit 2017Qt Automotive Suite - under the hood // Qt World Summit 2017
Qt Automotive Suite - under the hood // Qt World Summit 2017
 
Qt for Python
Qt for PythonQt for Python
Qt for Python
 
Migrating from Photon to Qt
Migrating from Photon to QtMigrating from Photon to Qt
Migrating from Photon to Qt
 
Migrating from Photon to Qt
Migrating from Photon to QtMigrating from Photon to Qt
Migrating from Photon to Qt
 
Qt for S60
Qt for S60Qt for S60
Qt for S60
 
Qt
QtQt
Qt
 
Qt for beginners part 1 overview and key concepts
Qt for beginners part 1   overview and key conceptsQt for beginners part 1   overview and key concepts
Qt for beginners part 1 overview and key concepts
 
PyQt Application Development On Maemo
PyQt Application Development On MaemoPyQt Application Development On Maemo
PyQt Application Development On Maemo
 
Best Practices in Qt Quick/QML - Part 3
Best Practices in Qt Quick/QML - Part 3Best Practices in Qt Quick/QML - Part 3
Best Practices in Qt Quick/QML - Part 3
 
So I downloaded Qt, Now What?
So I downloaded Qt, Now What?So I downloaded Qt, Now What?
So I downloaded Qt, Now What?
 
Plasmaquick Workshop - FISL 13
Plasmaquick Workshop - FISL 13Plasmaquick Workshop - FISL 13
Plasmaquick Workshop - FISL 13
 
CMake: Improving Software Quality and Process
CMake: Improving Software Quality and ProcessCMake: Improving Software Quality and Process
CMake: Improving Software Quality and Process
 
Necessitas - Qt on Android - from FSCONS 2011
Necessitas - Qt on Android - from FSCONS 2011Necessitas - Qt on Android - from FSCONS 2011
Necessitas - Qt on Android - from FSCONS 2011
 
Qt Workshop
Qt WorkshopQt Workshop
Qt Workshop
 
Building Cross-Platform Apps using Qt and Qyoto
Building Cross-Platform Apps using Qt and QyotoBuilding Cross-Platform Apps using Qt and Qyoto
Building Cross-Platform Apps using Qt and Qyoto
 
Hybrid and Multi-Cloud Strategies for Kubernetes with GitOps
Hybrid and Multi-Cloud Strategies for Kubernetes with GitOpsHybrid and Multi-Cloud Strategies for Kubernetes with GitOps
Hybrid and Multi-Cloud Strategies for Kubernetes with GitOps
 
Hybrid and Multi-Cloud Strategies for Kubernetes with GitOps
Hybrid and Multi-Cloud Strategies for Kubernetes with GitOpsHybrid and Multi-Cloud Strategies for Kubernetes with GitOps
Hybrid and Multi-Cloud Strategies for Kubernetes with GitOps
 
PyQt.pptx
PyQt.pptxPyQt.pptx
PyQt.pptx
 

Recently uploaded

Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - InfographicHr365.us smith
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfjoe51371421
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfkalichargn70th171
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfkalichargn70th171
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...soniya singh
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityNeo4j
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideChristina Lin
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number SystemsJheuzeDellosa
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software DevelopersVinodh Ram
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...ICS
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptkotipi9215
 
Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...aditisharan08
 
Engage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyEngage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyFrank van der Linden
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...MyIntelliSource, Inc.
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio, Inc.
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxComplianceQuest1
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...OnePlan Solutions
 

Recently uploaded (20)

Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - Infographic
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdf
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered Sustainability
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number Systems
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software Developers
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.ppt
 
Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...
 
Engage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyEngage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The Ugly
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...
 

Porting Motif Applications to Qt

  • 1. © Integrated Computer Solutions, Inc. All Rights Reserved Porting Motif Applications to Qt Jeff Tranter <jtranter@ics.com> Integrated Computer Solutions, Inc.
  • 2. © Integrated Computer Solutions, Inc. All Rights Reserved Agenda • Introduction • Anatomy of an Application • Toolkit Comparison • Development Environment • Inter-client Communication • Automation: GUI builders • I18N, Session Management and Help • Extras • Porting Your Application • Getting Help • References • Q&A
  • 3. © Integrated Computer Solutions, Inc. All Rights Reserved Introduction • Despite its age, many legacy Motif applications still in production. • A number of advantages to migrating to newer platforms. • Porting to Qt framework can achieve many of the benefits without requiring a total rewrite. • Will look at scenarios, strategies, and advice for porting Motif applications to Qt. • ICS has done many Motif to Qt conversions and you can benefit from our real-world experience.
  • 4. © Integrated Computer Solutions, Inc. All Rights Reserved What is Motif? • GUI toolkit for graphical desktop applications. • Emerged in the 1980s on UNIX workstations. • C based, uses X Windowing System. • Often used for high-end complex applications in domains like finance, engineering, RADAR, air traffic control, military. • Was commercial; made free for open source platforms (e.g. Linux) in 2000; released under LGPL in 2012. • Still some minimal maintenance being done, latest release 2.3.6 in 2016.
  • 5. © Integrated Computer Solutions, Inc. All Rights Reserved What is Qt? • Cross-platform application (not just GUI) framework. • C++ based. • Supports desktop, mobile, embedded platforms. • Commercial and open source (LGPL) licensing.
  • 6. © Integrated Computer Solutions, Inc. All Rights Reserved Reasons for Porting to Qt • Main incentive usually cross-platform or additional platform support (e.g. Windows, Mac). • Improve UX: color depth, higher-quality fonts, visual effects, native look and feel, localization. • Want to add new features that are difficult with Motif or want to leverage features of Qt (e.g. web view). • Desire to move from C to cleaner, type-safe, object-oriented code in C++. • Need a toolkit with professional support, bug fixes and frequent releases.
  • 7. © Integrated Computer Solutions, Inc. All Rights Reserved Reasons to Rewrite Rather Than Port • Moving to mobile, tablet, or embedded touchscreen platforms may require entirely new UX design. • May be moving to a platform that does not support Qt or C++. • May have decided to use native APIs on the new platform. • Current system is not maintainable, documented, understood or missing source code. • Want to entirely re-architect system.
  • 8. © Integrated Computer Solutions, Inc. All Rights Reserved Evaluating Your Application Effort and cost to port can vary depending on a number of factors: • Complexity of the existing application. • Hardware dependencies. • Available time and resources. • User expectations. • Handwritten GUI code vs. builder-generated UI code. • Use of third party or custom widgets or other third party code or libraries.
  • 9. © Integrated Computer Solutions, Inc. All Rights Reserved Evaluating Your Application • Understanding of existing design and code. • Hidden/undocumented features or behavior. • Existing unit and regression tests. • Documentation. • Your team's knowledge of Qt. • Commercial or open source version of Qt.
  • 10. © Integrated Computer Solutions, Inc. All Rights Reserved Anatomy of an Application • At a high level, both Motif and Qt: ● are event-driven. ● have similar basic widgets with hierarchical parent-child relationships. • Motif uses callbacks, Qt uses more sophisticated and safer signals and slots. • Qt separates widgets from layout managers.
  • 11. © Integrated Computer Solutions, Inc. All Rights Reserved Toolkit Comparison Description Motif Qt Initialize XtAppInitialize() QApplication() Create Widgets XmCreateWidgetName() QWidgetName() Event Response XtAddCallback() QObject::connect() Show Widget XtRealizeWidget() QWidget::show() Enter Event Loop XtAppMainLoop() QApplication::exec()
  • 12. © Integrated Computer Solutions, Inc. All Rights Reserved Hello Motif - Simple Motif Program With Callbacks #include <Xm/Xm.h> #include <Xm/MainW.h> #include <Xm/ToggleB.h> #include <stdio.h> #include <stdbool.h> void toggleChangedCB( Widget tb, XtPointer client_data, XtPointer call_data) { XmToggleButtonCallbackStruct *tbInfo = (XmToggleButtonCallbackStruct *)call_data; printf("The button state is: %sn", tbInfo->set == XmSET ? "ON" : "OFF"); printf("The app data is: %ldn", (long) client_data); } ...
  • 13. © Integrated Computer Solutions, Inc. All Rights Reserved Hello Motif - Simple Motif Program With Callbacks int main(int argc, char **argv) { Widget topLevel, mainW, tb; XtAppContext app; topLevel = XtVaOpenApplication(&app, "Example", NULL, 0, &argc, argv, NULL, sessionShellWidgetClass, NULL); mainW = XmCreateMainWindow(topLevel, "main_w", NULL, 0); tb = XmCreateToggleButton(mainW, "Hello Motif", NULL, 0); XtAddCallback(tb, XmNvalueChangedCallback, toggleChangedCB, (XtPointer) 42); XtManageChild(tb); XtManageChild(mainW); XtRealizeWidget(topLevel); XtAppMainLoop(app); return 0; }
  • 14. © Integrated Computer Solutions, Inc. All Rights Reserved Hello Motif - Simple Motif Program With Callbacks
  • 15. © Integrated Computer Solutions, Inc. All Rights Reserved Hello Qt – Simple Qt Program with Signals and Slots // qtexample.h #include <QObject> class SomeObj : public QObject { Q_OBJECT public: SomeObj(int objData) : QObject(nullptr), _objData(objData) {}; public slots: void toggled(bool toggleVal); protected: int _objData; };
  • 16. © Integrated Computer Solutions, Inc. All Rights Reserved Hello Qt – Simple Qt Program with Signals and Slots // qtexample.cpp #include <QtWidgets/QApplication> #include <QtWidgets/QPushButton> #include <QObject> #include <iostream> #include "qtexample.h" void SomeObj::toggled(bool toggleVal) { std::cerr << "The button state is: " << toggleVal << std::endl; std::cerr << "The app data is: " << _objData << std::endl; } ...
  • 17. © Integrated Computer Solutions, Inc. All Rights Reserved Hello Qt – Simple Qt Program with Signals and Slots int main(int argc, char ** argv) { QApplication app(argc, argv); QPushButton tb("Hello Qt"); tb.setCheckable(true); tb.setChecked(true); tb.show(); SomeObj myObject(42); QObject::connect(&tb, &QPushButton::toggled, &myObject, &SomeObj::toggled); return app.exec(); }
  • 18. © Integrated Computer Solutions, Inc. All Rights Reserved Hello Qt – Simple Qt Program with Signals and Slots
  • 19. © Integrated Computer Solutions, Inc. All Rights Reserved Toolkit Comparison – Common UI Objects Functionality Motif Qt Major Differences Text/Pixmap Label XmLabel QLabel QLabel can also display rich text or a movie. PushButton, ToggleButton XmPushButton, XmToggleButton QPushButton Same class offers both kinds of functionality. Otherwise similar. RadioButton, CheckBox XmToggleButton, XmRowColumn QCheckBox, QRadioButton, QButtonGroup In Motif, the parent RowColumn's resources dictate behavior. Scrollbar XmScrollBar QScrollBar Very similar. Scale XmScale QSlider Very similar. List of items XmList, XmContainer QListView QListView can do multicolumn, hierarchical lists of arbitrary type. Motif XmList is limited to single column, linear list of XmStrings, but XMContainer is as powerful. Single Line Text Field XmTextField QLineEdit QLineEdit supports rich text, encrypted entry, validator & built-in undo/redo. Text XmText QTextEdit Same as above. Also QPlainTextEdit for plain text. Horiz/Vert Tiled Windows XmPanedWindow QSplitter Very similar. SpinBox XmSpinBox QSpinBox Very similar.
  • 20. © Integrated Computer Solutions, Inc. All Rights Reserved Toolkit Comparison – Menus and Options Functionality Motif Qt Major Differences Horizontal Menubar XmMenuBar QMenuBar QMenuBar has several insertItem methods. Pulldown Menu XmPulldownMenu QMenu Qt provides a cleaner abstraction using QMenu as the common object for pulldowns and popups.Popup Menu XmCreatePopupMenu QMenu Option Menu, Combo Box XmComboBox, XmOptionMenu QComboBox Qt uses QComboBox for both.
  • 21. © Integrated Computer Solutions, Inc. All Rights Reserved Toolkit Comparison - Dialogs Functionality Motif Qt Error XmCreateErrorDialog QErrorMessage Information XmCreateInformationDialog QMessageBox Question XmCreateQuestionDialog QMessageBox Warning XmCreateWarningDialog QMessageBox Progress XmCreateWorkingDialog QProgressDialog Simple Input XmCreatePromptDialog QInputDialog File Chooser XmCreateFileDialog QFileDialog Item Chooser XmCreateSelectionDialog Use QListWidget or QListView Command History XmCreateCommand Use QListWidget or QListView Generic/Custom XmCreateMessageDialog QDialog
  • 22. © Integrated Computer Solutions, Inc. All Rights Reserved Toolkit Comparison – Complex Widgets • Main Window • OpenGL • Table • MDI • Tab Widget • GraphicsView • Frame
  • 23. © Integrated Computer Solutions, Inc. All Rights Reserved Toolkit Comparison - Complex Widgets • QDial • QLCDNumber • QDateTimeEdit • QToolBox • QToolBar, QToolButton • QDockWidget • QSplashScreen • QSvgWidget, QSvgRenderer, QSvgGenerator
  • 24. © Integrated Computer Solutions, Inc. All Rights Reserved Layout Management • XmBulletinBoard • XmScrolledWindow: QAbstractScrollArea, QScrollArea • XmRowColumn: QHBoxLayout, QVBoxLayout, QGridLayout • XmPanedWindow: QSplitter • XmFrame: QGroupBox (not QFrame) • XmRadioBox: QButtonGroup, QRadioButton • XmForm: implement using Qt's layout management
  • 25. © Integrated Computer Solutions, Inc. All Rights Reserved Layout Management Tips for layout management troubleshooting: • Use Qt Designer. • Use simple QWidgets with bright background colors or labels for all widgets in a layout. • May have to subclass certain widgets to override the sizeHint and minimumSizeHint values to be able to resize them properly.
  • 26. © Integrated Computer Solutions, Inc. All Rights Reserved Event Handling - Overview • Motif: At the basic level, each widget instance contains a translation table that maps events to procedure names. Another table, the action table, maps procedure names to actual procedures. When an event gets dispatched to a widget, the corresponding action procedure is invoked. • In Qt, events are delivered to objects derived from the base QObject class using the QObject::event interface.
  • 27. © Integrated Computer Solutions, Inc. All Rights Reserved Event Handling – Do Nothing • In Motif, widget instances “inherit” built-in event handlers that take care of the basic behavior (for example, pressing the backspace key in a text widget erases a character). • In Qt, the C++ inheritance model takes care of the default behavior of widget instances/subclasses.
  • 28. © Integrated Computer Solutions, Inc. All Rights Reserved Event Handling – Behavioral Events • Motif: programmer can add procedures for certain combinations of events. • Example: XmPushButton callbacks called when user presses and releases active mouse button inside the widget. • Qt has signals and slots. • Signal emitted when an event occurs. • Slot is a method called in response to a signal. • Signal from an object can be connected to a slot in any other object as long as type signature is compatible.
  • 29. © Integrated Computer Solutions, Inc. All Rights Reserved Event Handing – Finer Control • Motif: For finer control over event handling, the translation tables and actions procedures can be changed or added to Motif widgets. • Qt: Additional signals can be easily added in sub-classed Qt widgets.
  • 30. © Integrated Computer Solutions, Inc. All Rights Reserved Event Handling – Direct Dispatch • Motif: Application can register event handler procedures with the Xt event dispatcher for a particular widget. Procedures are called before the ones in the translation table. • Qt: QObject::event virtual method can be overridden to bypass or to add event handling for a widget. • Most Qt widgets have several event handling methods that are at a higher level of abstraction and can be overridden without completely changing the behavior of a widget through the lower level QObject::event method. • Qt widget can observe another widget’s events using the QObject::eventFilter, QObject::installEventFilter methods.
  • 31. © Integrated Computer Solutions, Inc. All Rights Reserved Event Handling – More Control • Some applications also grab the keyboard, pointer, or the entire server for specialized event handling. It is also possible to go down to the level of X11 to peek at, extract, resend events from the event queue. • In Qt, more control can be exercised using the available methods on the main application object to manipulate the event loop or by installing an application-wide event filter. Creation and dispatch of custom and non-GUI events is also possible.
  • 32. © Integrated Computer Solutions, Inc. All Rights Reserved Look and Feel • Motif has a unique look and feel. • Qt has some built-in styles that generally look native on the platform. • Support for CSS-like stylesheets, style plugins, or custom widgets.
  • 33. © Integrated Computer Solutions, Inc. All Rights Reserved Development Environment – Language, Compilers, Libraries • Need to develop at least some of your application in C++. • Can call existing C code if desired, or wrap it in C++ classes. • May need to port legacy code to build with modern compilers. • IDEs: Qt Creator, Visual Studio, vi/emacs... • Build system: qmake, cmake. • Dependencies on third-party libraries.
  • 34. © Integrated Computer Solutions, Inc. All Rights Reserved Dev. Environment – Distribution, Installation, Documentation • Qt available under open source and commercial license options. • Generally not hard to comply with license requirements. • Typically will want to ship Qt with your application. • Qt renowned for quality of developer documentation. • Doxygen tool for documenting your code, especially libraries. • May want install wizard on Windows, dmg on Mac OS, deb/rpm on Linux.
  • 35. © Integrated Computer Solutions, Inc. All Rights Reserved Inter-client Communication – Selection and Clipboard • X Windows supports Primary selection and Clipboard selection. • Primary selection enables availability of data as soon as selected. • Clipboard provides more traditional support by making data available explicitly using copy or cut operation. • Qt has built-in support for both using the QClipboard class.
  • 36. © Integrated Computer Solutions, Inc. All Rights Reserved Inter-client Communication – Drag and Drop • Drag and Drop can be used to transfer data within and between applications. • Motif’s support of drag and drop implemented on top of the selection mechanisms provided by Xt and the X ICCCM. • Under X11, Drag and Drop support in Qt based on the XDND protocol. • Relevant Qt classes: QDrag, QDragEnterEvent, QDragLeaveEvent, QDragMoveEvent, QDropEvent
  • 37. © Integrated Computer Solutions, Inc. All Rights Reserved Automation – GUI Builder • Qt provides Qt Designer GUI builder. • Allows laying out windows, widgets, dialogs and other elements. • Can set properties and connect signals and slots. • Saved as XML, which is then used to generate C++ code using uic. • Generally considered best practice to use it.
  • 38. © Integrated Computer Solutions, Inc. All Rights Reserved Scripting • Qt provides support for application scripting with ECMAScript (JavaScript). • See QScriptEngine and related classes • Considered deprecated for new applications. Instead use QJSEngine class which is part of QML. • Also support for JavaScript in browser via QtWebEngine. • Qt applications can also be written entirely in Python using PyQt or PySide bindings.
  • 39. © Integrated Computer Solutions, Inc. All Rights Reserved Testing and Inspection • Qt provides Qt Test module, a framework for unit testing. • Can also use Google Test, etc. with Qt. • For automated, functional, scripting GUI record/playback testing, recommend commercial SQUISH tool. • Various debug and analysis tools, some available from Qt Creator and some external (e.g. Gamma Ray).
  • 40. © Integrated Computer Solutions, Inc. All Rights Reserved Localization and Internationalization • QString: uses Unicode. • QObject::tr(): For translating user visible strings. • Translations looked up at run time from a catalog. • Tools: ● lupdate: Extracts translatable strings from source files. ● Linguist: Application for translators to enter translations. ● lrelease: Creates compact binary table used at run time. • Support for various languages using Qt's text engine for all input (QTextEdit, QLineEdit) and display (QLabel) controls. • Support for localized formats for numbers, times, timezones, dates, currency, etc.
  • 41. © Integrated Computer Solutions, Inc. All Rights Reserved Session Management • Often a requirement for applications to save settings or state. • X11 applications can register with X Session Manager. • Supported in Qt by QSessionManager class. • More common just to save settings using QSettings class.
  • 42. © Integrated Computer Solutions, Inc. All Rights Reserved Help • Limited support in Motif for application help (callback for context sensitive help and tooltip resource). • Qt provides tooltips when hovering over a widget, What's This? help, status bar. • Applications can use Qt's hypertext help system used by Assistant (QHelpEngine and related classes). • Could also implement HTML-based help in a web view.
  • 43. © Integrated Computer Solutions, Inc. All Rights Reserved Extras • Unlike Motif, Qt is much more than a GUI toolkit. • Support for: ● I/O, networking ● Images ● XML ● Date/time ● SQL databases ● Strings, containers ● Model/View pattern ● Threading ● Resource system
  • 44. © Integrated Computer Solutions, Inc. All Rights Reserved Porting Your Application • Recommend to start with small non-mission critical application to port first. • Learn, gain experience, add more features. • Gain experience, and then move on to larger applications next.
  • 45. © Integrated Computer Solutions, Inc. All Rights Reserved Port or Redesign? • Porting effort can have large impact on architecture for complex applications. • May want to re-architect. • Opportunity to modernize. • More object-oriented design. • Model/View architecture to separate visual design from data.
  • 46. © Integrated Computer Solutions, Inc. All Rights Reserved Gradual Migration • Qt Motif Extension allowed running Motif widgets in a Qt application. • Was dropped in Qt 4, but still works with a few code changes. • Porting to Qt 5 difficult as Qt now uses xcb and not xlib.
  • 47. © Integrated Computer Solutions, Inc. All Rights Reserved Porting Strategies for Applications • Will look at some different porting strategies. • Often initial port stays on Linux/UNIX, then later moves to other platforms.
  • 48. © Integrated Computer Solutions, Inc. All Rights Reserved Porting Strategies – Hand Written GUI • Dynamic layout of widgets. • Custom layout or constraints. • Hard to implement using GUI builder. • Typically can do this with Qt's layout engine.
  • 49. © Integrated Computer Solutions, Inc. All Rights Reserved Porting Strategies – GUI Builder Generated • e.g. using Builder Xcessory (BX Pro) GUI builder tool on Motif. • Typically convert to Qt Designer. • Automated conversion possible in theory.
  • 50. © Integrated Computer Solutions, Inc. All Rights Reserved Porting Strategies – C Based • Need to port some or all of your code to C++. • Your team may need to learn object-oriented design. • Maybe require re-architecting (e.g. to separate GUI from business logic).
  • 51. © Integrated Computer Solutions, Inc. All Rights Reserved Porting Strategies – Graphics Heavy • Qt port can be opportunity to better leverage modern graphics hardware. • Many facilities available in Qt (QPainter, QGraphicsView, OpenGL). • OpenGL code can be ported quite easily. • X11 painting code straightforward to port to Qt's painter API.
  • 52. © Integrated Computer Solutions, Inc. All Rights Reserved Porting Strategies – Custom Widgets • Custom widgets in Motif are very complex, typically 10K-20K LOC. • Much easier with Qt, subclass existing widget or QWidget. • Qt custom widgets have properties with setters and getters, can be used with Designer. • Don't have to implement layout management in the widget.
  • 53. © Integrated Computer Solutions, Inc. All Rights Reserved Porting Strategies – Custom Widgets Description Motif Qt Initialize ClassInitialize, Initialize, Create widget constructor(s) Re-render the widget Redisplay update(), repaint() Draw the widget DrawVisual, DrawShadow paintEvent, QPainter Optimal widget size WidgetSize, VisualSize sizeHint Accommodate widget Resize adjustSize Changes in resource setValues public set/get methods Event handling Callbacks/actions/translations events, signals & slots Geometry management geometry_manager QLayout Event propagation parent_process automatic, event filter
  • 54. © Integrated Computer Solutions, Inc. All Rights Reserved Getting Help • Porting can be a significant effort. • Can also involve re-architecting application. • Consider bringing in outside consultants for: ● assistance (staff augmentation). ● turnkey porting. ● training, mentoring. ● UX design.
  • 55. © Integrated Computer Solutions, Inc. All Rights Reserved References 1. Qt website, https://www.qt.io/ 2. ICS Motif website, http://motif.ics.com/ 3. Porting X/Motif Applications to Qt, Scenarios and Advice for a Smooth Migration, ICS whitepaper, https://motif.ics.com/sites/default/files/porting_motif_to_qt.pdf
  • 56. © Integrated Computer Solutions, Inc. All Rights Reserved Questions and Answers
  • 57. © Integrated Computer Solutions, Inc. All Rights Reserved Porting Motif Applications to Qt Jeff Tranter <jtranter@ics.com> Integrated Computer Solutions, Inc.