Home | All Classes | Main Classes | Annotated | Grouped Classes | Functions |

# Using the Motif Event Loop

Header

    #ifndef MAINWINDOW_H
    #define MAINWINDOW_H

    #include <ntqmainwindow.h>

    class TQMotifWidget;

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

    private:
        TQMotifWidget *customwidget;
    };

    #endif // MAINWINDOW_H

Implementation:

    #include "mainwindow.h"

    #include <ntqapplication.h>
    #include <qmotif.h>

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

        TQMotif integrator( "customwidget" );
        TQApplication app( argc, argv );

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

        return app.exec();
    }

    #include "mainwindow.h"

    #include <ntqapplication.h>
    #include <ntqmenubar.h>
    #include <ntqpopupmenu.h>
    #include <ntqstatusbar.h>

    #include <qmotifwidget.h>

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

    MainWindow::MainWindow()
        : TQMainWindow( 0, "mainwindow" )
    {
        TQPopupMenu *filemenu = new TQPopupMenu( this );
        filemenu->insertItem( tr("&Quit"), tqApp, SLOT(quit()) );

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

        customwidget =
            new TQMotifWidget( 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 TQMotif Support Extension.