source: trunk/doc/html/motif-customwidget-example.html@ 203

Last change on this file since 203 was 190, checked in by rudi, 14 years ago

reference documentation added

File size: 5.1 KB
Line 
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"><!--
8fn { margin-left: 1cm; text-indent: -1cm; }
9a:link { color: #004faf; text-decoration: none }
10a:visited { color: #672967; text-decoration: none }
11body { 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&nbsp;Classes</font></a>
23 | <a href="mainclasses.html">
24<font color="#004faf">Main&nbsp;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&nbsp;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 &lt;<a href="qmainwindow-h.html">qmainwindow.h</a>&gt;
43
44
45class QMotifWidget;
46
47class MainWindow : public <a href="qmainwindow.html">QMainWindow</a>
48{
49public:
50 MainWindow();
51
52private:
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 &lt;<a href="qapplication-h.html">qapplication.h</a>&gt;
64#include &lt;<a href="qmotif-h.html">qmotif.h</a>&gt;
65
66
67int 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>( &amp;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 &lt;<a href="qapplication-h.html">qapplication.h</a>&gt;
85#include &lt;<a href="qmenubar-h.html">qmenubar.h</a>&gt;
86#include &lt;<a href="qpopupmenu-h.html">qpopupmenu.h</a>&gt;
87#include &lt;<a href="qstatusbar-h.html">qstatusbar.h</a>&gt;
88
89#include &lt;<a href="qmotifwidget-h.html">qmotifwidget.h</a>&gt;
90
91#include &lt;Xm/Form.h&gt;
92#include &lt;Xm/PushB.h&gt;
93#include &lt;Xm/Text.h&gt;
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-&gt;<a href="qmenudata.html#insertItem">insertItem</a>( <a href="qobject.html#tr">tr</a>("&amp;Quit"), qApp, SLOT(<a href="qapplication.html#quit">quit</a>()) );
101
102 <a href="qmainwindow.html#menuBar">menuBar</a>()-&gt;insertItem( <a href="qobject.html#tr">tr</a>("&amp;File"), filemenu );
103 <a href="qmainwindow.html#statusBar">statusBar</a>()-&gt;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-&gt;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-&gt;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 &copy; 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>
Note: See TracBrowser for help on using the repository browser.