Home

Qt Motif Extension

Introduction

The Qt Motif extension assists the migration of old Xt and Motif based applications to the more comfortable Qt toolkit. This extension replaces the older Xt/Motif Support Extension included with earlier versions of Qt.

This extension is typically used by developers when incrementally migrating Motif-based applications to Qt. To take full advantage of Qt, we recommend that you ship complete Qt ports of your applications rather than rely on this extension in production software.

The Qt Motif extension consists of the following classes:

See also the following examples:

Common Problems

Incorrect CDE Color Scheme

QtMotifWidget and QtMotifDialog will use the same Visual, Colormap, and color depth that QApplication uses. But when using CDE, the color scheme may be incorrect if the Visual, Colormap, and color depth are not the same as the defaults. To work around this problem, add the following resource string to your startup files (for example, $HOME/.dt/sessions/current/dt.resources):

 *userColorObj: false

X11 Header Conflicts

The X11 headers define some constants that conflict with the Qt headers. The solution is to include all Qt headers first, followed by headers from this extension, and all Xt/Motif and X11 headers last.

For example:

 // Qt headers first
 #include <QApplication>
 #include <QPushButton>
 #include <QTcpSocket>
 ...

 // QtMotif* headers next
 #include <QtMotif>
 #include <QtMotifDialog>
 #include <QtMotifWidget>

 // Xt/Motif and X11 headers last
 #include <X11/Xlib.h>
 #include <Xt/Intrinsic.h>
 #include <Xm/Xm.h>
 ...

Multiple Screen Support

QtMotifWidget can be used together with QDesktopWidget to create top-level windows on multiple screens. A common mistake is to create a QtMotifWidget on a non-default screen while the Xt/Motif widgets are created on the default screen. The solution is to specify the screen to both QtMotifWidget and the Xt/Motif child. For example:

 Display *dpy = QX11Info::display();
 Arg args[1];

 // make sure both QtMotifWidget and the XmMainWindow are on screen 1
 XtSetArg(args[0], XtNscreen, ScreenOfDisplay(dpy, 1));
 QtMotifWidget *toplevel =
     new QtMotifWidget(QApplication::desktop()->screen(1),
                      xmMainWindowWidgetClass, args, 1, "mainwindow");


Copyright © 2009 Nokia Corporation and/or its subsidiary(-ies) Trademarks
Qt Solutions