DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 
Home | All Classes | Main Classes | Annotated | Grouped Classes | Functions

Using the Motif Event Loop


Header

#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <qmainwindow.h>


class QMotifWidget;

class MainWindow : public QMainWindow
{
public:
    MainWindow();

private:
    QMotifWidget *customwidget;
};

#endif // MAINWINDOW_H


Implementation:

#include "mainwindow.h"

#include <qapplication.h>
#include <qmotif.h>


int main( int argc, char **argv )
{
    XtSetLanguageProc( NULL, NULL, NULL );

    QMotif integrator( "customwidget" );
    QApplication app( argc, argv );

    MainWindow mainwindow;
    app.setMainWidget( &mainwindow );
    mainwindow.show();

    return app.exec();
}

#include "mainwindow.h"

#include <qapplication.h>
#include <qmenubar.h>
#include <qpopupmenu.h>
#include <qstatusbar.h>

#include <qmotifwidget.h>

#include <Xm/Form.h>
#include <Xm/PushB.h>
#include <Xm/Text.h>


MainWindow::MainWindow()
    : QMainWindow( 0, "mainwindow" )
{
    QPopupMenu *filemenu = new QPopupMenu( this );
    filemenu->insertItem( tr("&Quit"), qApp, SLOT(quit()) );

    menuBar()->insertItem( tr("&File"), filemenu );
    statusBar()->message( tr("This is a QMainWindow with an XmText widget.") );

    customwidget =
        new QMotifWidget( this, xmFormWidgetClass, NULL, 0, "form" );

    XmString str;
    Arg args[6];

    str = XmStringCreateLocalized( "Push Button (XmPushButton)" );
    XtSetArg( args[0], XmNlabelString, str );
    XtSetArg( args[1], XmNleftAttachment, XmATTACH_FORM );
    XtSetArg( args[2], XmNrightAttachment, XmATTACH_FORM );
    XtSetArg( args[3], XmNbottomAttachment, XmATTACH_FORM );
    Widget button =
        XmCreatePushButton( customwidget->motifWidget(), "Push Button", args, 4 );
    XmStringFree( str );

    XtSetArg( args[0], XmNeditMode, XmMULTI_LINE_EDIT );
    XtSetArg( args[1], XmNleftAttachment, XmATTACH_FORM );
    XtSetArg( args[2], XmNrightAttachment, XmATTACH_FORM );
    XtSetArg( args[3], XmNtopAttachment, XmATTACH_FORM );
    XtSetArg( args[4], XmNbottomAttachment, XmATTACH_WIDGET );
    XtSetArg( args[5], XmNbottomWidget, button );
    Widget texteditor =
        XmCreateScrolledText( customwidget->motifWidget(), "Text Editor", args, 6 );

    XtManageChild( texteditor );
    XtManageChild( button );

    setCentralWidget( customwidget );

    resize( 400, 600 );
}

See also QMotif Support Extension.


Copyright © 2007 TrolltechTrademarks
Qt 3.3.8