1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
---|
2 | <!-- /home/espenr/tmp/qt-3.3.8-espenr-2499/qt-x11-free-3.3.8/extensions/motif/examples/customwidget/customwidget.doc:1 -->
|
---|
3 | <html>
|
---|
4 | <head>
|
---|
5 | <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
---|
6 | <title>Using the Motif Event Loop</title>
|
---|
7 | <style type="text/css"><!--
|
---|
8 | fn { margin-left: 1cm; text-indent: -1cm; }
|
---|
9 | a:link { color: #004faf; text-decoration: none }
|
---|
10 | a:visited { color: #672967; text-decoration: none }
|
---|
11 | body { background: #ffffff; color: black; }
|
---|
12 | --></style>
|
---|
13 | </head>
|
---|
14 | <body>
|
---|
15 |
|
---|
16 | <table border="0" cellpadding="0" cellspacing="0" width="100%">
|
---|
17 | <tr bgcolor="#E5E5E5">
|
---|
18 | <td valign=center>
|
---|
19 | <a href="index.html">
|
---|
20 | <font color="#004faf">Home</font></a>
|
---|
21 | | <a href="classes.html">
|
---|
22 | <font color="#004faf">All Classes</font></a>
|
---|
23 | | <a href="mainclasses.html">
|
---|
24 | <font color="#004faf">Main Classes</font></a>
|
---|
25 | | <a href="annotated.html">
|
---|
26 | <font color="#004faf">Annotated</font></a>
|
---|
27 | | <a href="groups.html">
|
---|
28 | <font color="#004faf">Grouped Classes</font></a>
|
---|
29 | | <a href="functions.html">
|
---|
30 | <font color="#004faf">Functions</font></a>
|
---|
31 | </td>
|
---|
32 | <td align="right" valign="center"><img src="logo32.png" align="right" width="64" height="32" border="0"></td></tr></table><h1 align=center>Using the Motif Event Loop</h1>
|
---|
33 |
|
---|
34 |
|
---|
35 | <p>
|
---|
36 | <p>
|
---|
37 | <p> <hr>
|
---|
38 | <p> Header
|
---|
39 | <p> <pre>#ifndef MAINWINDOW_H
|
---|
40 | #define MAINWINDOW_H
|
---|
41 |
|
---|
42 | #include <<a href="qmainwindow-h.html">qmainwindow.h</a>>
|
---|
43 |
|
---|
44 |
|
---|
45 | class QMotifWidget;
|
---|
46 |
|
---|
47 | class MainWindow : public <a href="qmainwindow.html">QMainWindow</a>
|
---|
48 | {
|
---|
49 | public:
|
---|
50 | MainWindow();
|
---|
51 |
|
---|
52 | private:
|
---|
53 | <a href="qmotifwidget.html">QMotifWidget</a> *customwidget;
|
---|
54 | };
|
---|
55 |
|
---|
56 | #endif // MAINWINDOW_H
|
---|
57 | </pre>
|
---|
58 |
|
---|
59 | <p> <hr>
|
---|
60 | <p> Implementation:
|
---|
61 | <p> <pre>#include "mainwindow.h"
|
---|
62 |
|
---|
63 | #include <<a href="qapplication-h.html">qapplication.h</a>>
|
---|
64 | #include <<a href="qmotif-h.html">qmotif.h</a>>
|
---|
65 |
|
---|
66 |
|
---|
67 | int main( int argc, char **argv )
|
---|
68 | {
|
---|
69 | XtSetLanguageProc( NULL, NULL, NULL );
|
---|
70 |
|
---|
71 | <a href="qmotif.html">QMotif</a> integrator( "customwidget" );
|
---|
72 | <a href="qapplication.html">QApplication</a> app( argc, argv );
|
---|
73 |
|
---|
74 | MainWindow mainwindow;
|
---|
75 | app.<a href="qapplication.html#setMainWidget">setMainWidget</a>( &mainwindow );
|
---|
76 | mainwindow.<a href="qwidget.html#show">show</a>();
|
---|
77 |
|
---|
78 | return app.<a href="qapplication.html#exec">exec</a>();
|
---|
79 | }
|
---|
80 | </pre>
|
---|
81 |
|
---|
82 | <p> <pre>#include "mainwindow.h"
|
---|
83 |
|
---|
84 | #include <<a href="qapplication-h.html">qapplication.h</a>>
|
---|
85 | #include <<a href="qmenubar-h.html">qmenubar.h</a>>
|
---|
86 | #include <<a href="qpopupmenu-h.html">qpopupmenu.h</a>>
|
---|
87 | #include <<a href="qstatusbar-h.html">qstatusbar.h</a>>
|
---|
88 |
|
---|
89 | #include <<a href="qmotifwidget-h.html">qmotifwidget.h</a>>
|
---|
90 |
|
---|
91 | #include <Xm/Form.h>
|
---|
92 | #include <Xm/PushB.h>
|
---|
93 | #include <Xm/Text.h>
|
---|
94 |
|
---|
95 |
|
---|
96 | <a name="f563"></a>MainWindow::MainWindow()
|
---|
97 | : <a href="qmainwindow.html">QMainWindow</a>( 0, "mainwindow" )
|
---|
98 | {
|
---|
99 | <a href="qpopupmenu.html">QPopupMenu</a> *filemenu = new <a href="qpopupmenu.html">QPopupMenu</a>( this );
|
---|
100 | filemenu-><a href="qmenudata.html#insertItem">insertItem</a>( <a href="qobject.html#tr">tr</a>("&Quit"), qApp, SLOT(<a href="qapplication.html#quit">quit</a>()) );
|
---|
101 |
|
---|
102 | <a href="qmainwindow.html#menuBar">menuBar</a>()->insertItem( <a href="qobject.html#tr">tr</a>("&File"), filemenu );
|
---|
103 | <a href="qmainwindow.html#statusBar">statusBar</a>()->message( <a href="qobject.html#tr">tr</a>("This is a QMainWindow with an XmText widget.") );
|
---|
104 |
|
---|
105 | customwidget =
|
---|
106 | new <a href="qmotifwidget.html">QMotifWidget</a>( this, xmFormWidgetClass, NULL, 0, "form" );
|
---|
107 |
|
---|
108 | XmString str;
|
---|
109 | Arg args[6];
|
---|
110 |
|
---|
111 | str = XmStringCreateLocalized( "Push Button (XmPushButton)" );
|
---|
112 | XtSetArg( args[0], XmNlabelString, str );
|
---|
113 | XtSetArg( args[1], XmNleftAttachment, XmATTACH_FORM );
|
---|
114 | XtSetArg( args[2], XmNrightAttachment, XmATTACH_FORM );
|
---|
115 | XtSetArg( args[3], XmNbottomAttachment, XmATTACH_FORM );
|
---|
116 | Widget button =
|
---|
117 | XmCreatePushButton( customwidget->motifWidget(), "Push Button", args, 4 );
|
---|
118 | XmStringFree( str );
|
---|
119 |
|
---|
120 | XtSetArg( args[0], XmNeditMode, XmMULTI_LINE_EDIT );
|
---|
121 | XtSetArg( args[1], XmNleftAttachment, XmATTACH_FORM );
|
---|
122 | XtSetArg( args[2], XmNrightAttachment, XmATTACH_FORM );
|
---|
123 | XtSetArg( args[3], XmNtopAttachment, XmATTACH_FORM );
|
---|
124 | XtSetArg( args[4], XmNbottomAttachment, XmATTACH_WIDGET );
|
---|
125 | XtSetArg( args[5], XmNbottomWidget, button );
|
---|
126 | Widget texteditor =
|
---|
127 | XmCreateScrolledText( customwidget->motifWidget(), "Text Editor", args, 6 );
|
---|
128 |
|
---|
129 | XtManageChild( texteditor );
|
---|
130 | XtManageChild( button );
|
---|
131 |
|
---|
132 | <a href="qmainwindow.html#setCentralWidget">setCentralWidget</a>( customwidget );
|
---|
133 |
|
---|
134 | <a href="qwidget.html#resize">resize</a>( 400, 600 );
|
---|
135 | }
|
---|
136 |
|
---|
137 | </pre>
|
---|
138 |
|
---|
139 | <p> <p>See also <a href="motif-examples.html">QMotif Support Extension</a>.
|
---|
140 |
|
---|
141 | <!-- eof -->
|
---|
142 | <p><address><hr><div align=center>
|
---|
143 | <table width=100% cellspacing=0 border=0><tr>
|
---|
144 | <td>Copyright © 2007
|
---|
145 | <a href="troll.html">Trolltech</a><td align=center><a href="trademarks.html">Trademarks</a>
|
---|
146 | <td align=right><div align=right>Qt 3.3.8</div>
|
---|
147 | </table></div></address></body>
|
---|
148 | </html>
|
---|