Details
-
Bug
-
Resolution: Out of scope
-
P3: Somewhat important
-
Release 6
-
None
Description
When using QtMotif, if you set the window title of a topLevel widget after its creation the title bar is not updated.
There is a small example provided by the customer. Use option -q or -qb to see the difference.
#define XTNULL ((void *)0)
#define vMargin (15)
#define hMargin vMargin
#include <QApplication>
#include <qtmotifwidget.h>
#include <qtmotif.h>
#include <Xm/MainW.h>
#include <Xm/Form.h>
#include <Xm/Label.h>
#include <unistd.h>
#include <string.h>
static char *resources[] = {
"*XmList*Background: #CECECE",
NULL
};
const char *app_class = "AppClass";
const char *app_name = "qtmotif";
void file_cb (Widget widget /* menu item that was selected */
,XtPointer client_data /* the index into the menu */
,XtPointer call_data /* unused */ ) {
int item_no = (int)client_data;
switch (item_no)
{ case 0: /* "Quit" */ exit(0); break; } return;
}
int main (int argc, char *argv[]) {
bool bUseMotif = false;
bool bUseQtAppClass = false;
bool bSetTitleBefore = false;
Widget topLevel, MainWindow;
XtAppContext app_context;
int c, ret;
QtMotifWidget *mw;
QApplication *app;
QtMotif *integrator;
// Check command-line options.
while ((c = getopt(argc, argv, "bmqh")) != EOF) {
switch (c)
}
if (!bUseMotif && !bUseQtAppClass)
{ printf("No mode specified.\n"); return 1; }if (bUseMotif && bUseQtAppClass)
{ printf(">1 mode specified.\n"); return 1; }if (bUseMotif)
{ // Initialize Xt. topLevel = XtAppInitialize(&app_context, app_class, NULL, 0, &argc, argv, resources, NULL, 0); // Create the XmMainWindow. MainWindow = XtVaCreateWidget(app_name, xmMainWindowWidgetClass, topLevel, XTNULL); }else
{ // Initialize QtMotif . integrator = new QtMotif(app_class); XtAppSetFallbackResources(integrator->applicationContext(), resources); // Initialize Qt . app = new QApplication(argc, argv); mw = new QtMotifWidget(app_name, applicationShellWidgetClass, 0, NULL, 0); topLevel = mw->motifWidget(); // Create the XmMainWindow. MainWindow = XtVaCreateWidget(app_name, xmMainWindowWidgetClass, topLevel, XTNULL); }/***********************************************************************/
// Create the menu.
XmString file = XmStringCreateLocalized ("File");
XmString help = XmStringCreateLocalized ("Help");
Widget menuBar = XmVaCreateSimpleMenuBar (MainWindow, "menuBar",
XmVaCASCADEBUTTON, file, 'F',
XmVaCASCADEBUTTON, help, 'H',
NULL);
// Tell the menu bar which button is the help menu.
if (Widget widget = XtNameToWidget(menuBar, "button_1"))
// Add stuff to the File menu.
XmString quit = XmStringCreateLocalized ("Quit");
XmVaCreateSimplePulldownMenu(menuBar, "file_menu", 0, file_cb,
XmVaPUSHBUTTON, quit, 'Q', NULL, NULL,
NULL);
// Done creating the menu bar.
XtManageChild(menuBar);
// Tell the XmMainWindow who its menu bar is. Set some other options, too.
XtVaSetValues(MainWindow,
XmNmenuBar, menuBar,
XmNshowSeparator, True,
XTNULL);
// Create the work area form.
Widget main_form = XtVaCreateWidget("main_form", xmFormWidgetClass, MainWindow,
XmNresizable, True,
XTNULL);
XtVaSetValues(MainWindow, XmNworkWindow, main_form, XTNULL);
Widget info_form = XtVaCreateWidget("info_form", xmFormWidgetClass, main_form,
XmNmarginHeight, vMargin,
XmNmarginWidth, hMargin,
XmNrightAttachment, XmATTACH_FORM,
XmNleftAttachment, XmATTACH_FORM,
XmNtopAttachment, XmATTACH_FORM,
XmNbottomAttachment, XmATTACH_NONE,
XmNresizable, True,
XTNULL);
Widget project_name = XtVaCreateWidget("project_name", xmLabelWidgetClass, info_form,
XmNlabelString, XmStringCreateLocalized("PROJECT: my project name"),
XmNalignment, XmALIGNMENT_BEGINNING,
XmNrightAttachment, XmATTACH_POSITION, XmNrightPosition, 50,
XmNleftAttachment, XmATTACH_FORM,
XmNtopAttachment, XmATTACH_FORM,
XmNbottomAttachment, XmATTACH_NONE,
XmNresizable, True,
XTNULL);
Widget line_name = XtVaCreateWidget("line_name", xmLabelWidgetClass, info_form,
XmNlabelString, XmStringCreateLocalized("LINE: my line name"),
XmNalignment, XmALIGNMENT_END,
XmNrightAttachment, XmATTACH_FORM,
XmNleftAttachment, XmATTACH_POSITION, XmNleftPosition, 50,
XmNtopAttachment, XmATTACH_FORM,
XmNbottomAttachment, XmATTACH_NONE,
XmNresizable, True,
XTNULL);
XtManageChild(line_name);
XtManageChild(project_name);
XtManageChild(info_form);
XtManageChild(main_form);
// Create the message area form.
Widget help_form = XtCreateWidget("help_form", xmFormWidgetClass, MainWindow, NULL, 0);
XtVaSetValues(MainWindow, XmNmessageWindow, help_form, XTNULL);
Widget message = XtVaCreateWidget("message", xmLabelWidgetClass, help_form,
XmNlabelString, XmStringCreateLocalized("This is the message area."),
XmNalignment, XmALIGNMENT_BEGINNING,
XmNtopAttachment, XmATTACH_FORM,
XmNleftAttachment, XmATTACH_FORM,
XmNbottomAttachment, XmATTACH_NONE,
XmNrightAttachment, XmATTACH_NONE,
XTNULL);
XtManageChild(message);
XtManageChild(help_form);
/***********************************************************************/
if (bUseMotif)
{ XtManageChild(MainWindow); if (bSetTitleBefore) XtVaSetValues(topLevel, XmNtitle, "This is a test program...", XTNULL); XtRealizeWidget(topLevel); if (!bSetTitleBefore) XtVaSetValues(topLevel, XmNtitle, "This is a test program...", XTNULL); XtAppMainLoop(app_context); ret = 0; }else
{ XtManageChild(MainWindow); if (bSetTitleBefore) XtVaSetValues(topLevel, XmNtitle, "This is a test program...", XTNULL); XtRealizeWidget(topLevel); if (!bSetTitleBefore) XtVaSetValues(topLevel, XmNtitle, "This is a test program...", XTNULL); // Start Qt event loop. ret = app->exec(); } return ret;
}