<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <!-- /tmp/qt-3.0-reggie-28534/qt-x11-free-3.0.2/extensions/xt/examples/mainlyXt/editor.doc:1 --> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <title>Editors in an Xt form</title> <style type="text/css"><!-- h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm; } a:link { color: #004faf; text-decoration: none } a:visited { color: #672967; text-decoration: none } body { background: #ffffff; color: black; } --></style> </head> <body> <table border="0" cellpadding="0" cellspacing="0" width="100%"> <tr bgcolor="#E5E5E5"> <td valign=center> <a href="index.html"> <font color="#004faf">Home</font></a> | <a href="classes.html"> <font color="#004faf">All Classes</font></a> | <a href="mainclasses.html"> <font color="#004faf">Main Classes</font></a> | <a href="annotated.html"> <font color="#004faf">Annotated</font></a> | <a href="groups.html"> <font color="#004faf">Grouped Classes</font></a> | <a href="functions.html"> <font color="#004faf">Functions</font></a> </td> <td align="right" valign="center"><img src="logo32.png" align="right" width="64" height="32" border="0"></td></tr></table><h1 align=center>Editors in an Xt form</h1> <p> This example shows two simple text editors, with most of the program written in Xt. One editor is a Qt QMultiLineEdit, the other is an Athena Widgets text widget. They are bound together in an Xt form widget. <hr> Implementation: <p> <pre>#include "qxt.h" #include <<a href="qmultilineedit-h.html">qmultilineedit.h</a>> #include <<a href="qpainter-h.html">qpainter.h</a>> #include <<a href="qmessagebox-h.html">qmessagebox.h</a>> #include <X11/Shell.h> #include <X11/StringDefs.h> #include <X11/Xaw/Form.h> #include <X11/Xaw/AsciiText.h> static const char* QTEDMSG = "This is a Qt widget.\nIt is a QMultiLineEdit."; static const char* XTEDMSG = "This is an Xt widget.\nIt is an asciiTextWidgetClass."; class EncapsulatedQtWidget : public <a href="qxtwidget.html">QXtWidget</a> { public: <a href="qmultilineedit.html">QMultiLineEdit</a>* mle; EncapsulatedQtWidget(Widget parent) : <a href="qxtwidget.html">QXtWidget</a>("editor", parent, TRUE) { mle = new <a href="qmultilineedit.html">QMultiLineEdit</a>(this); <a name="x2572"></a> mle-><a href="qtextedit.html#setText">setText</a>(QTEDMSG); } void resizeEvent(QResizeEvent* e ) { <a name="x2574"></a> QXtWidget::<a href="qwidget.html#resizeEvent">resizeEvent</a>( e ); mle-><a href="qwidget.html#resize">resize</a>(width(),height()); } }; int main(int argc, char** argv) { XtAppContext app; Widget toplevel = XtAppInitialize( &app, "Editors", 0, 0, &argc, argv, 0, 0, 0); <a href="qxtapplication.html">QXtApplication</a> qapp(XtDisplay(toplevel)); Widget form = XtVaCreateManagedWidget("form", formWidgetClass, toplevel, 0); EncapsulatedQtWidget qtchild(form); Arg args[20]; Cardinal nargs=0; XtSetArg(args[nargs], XtNwidth, 200); nargs++; XtSetArg(args[nargs], XtNheight, 200); nargs++; <a name="x2576"></a> XtSetValues(qtchild.<a href="qxtwidget.html#xtWidget">xtWidget</a>(), args, nargs); nargs=0; XtSetArg(args[nargs], XtNeditType, XawtextEdit); nargs++; XtSetArg(args[nargs], XtNstring, XTEDMSG); nargs++; XtSetArg(args[nargs], XtNwidth, 200); nargs++; XtSetArg(args[nargs], XtNheight, 200); nargs++; XtSetArg(args[nargs], XtNfromHoriz, qtchild.<a href="qxtwidget.html#xtWidget">xtWidget</a>()); nargs++; Widget xtchild = XtCreateManagedWidget("editor", asciiTextWidgetClass, form, args, nargs); XtRealizeWidget(toplevel); <a name="x2575"></a>// XSetInputFocus( qt_xdisplay(), qtchild.mle-><a href="qwidget.html#winId">winId</a>(), RevertToParent, CurrentTime ); //XtAppMainLoop(app); // or the equivalent: XEvent xe; while (1) { XtAppNextEvent(app, &xe); XtDispatchEvent(&xe); } } </pre> <p>See also <a href="xt-motif-examples.html">Qt Xt/Motif Support Extension</a>. <!-- eof --> <p><address><hr><div align=center> <table width=100% cellspacing=0 border=0><tr> <td>Copyright © 2001 <a href="http://www.trolltech.com">Trolltech</a><td><a href="http://www.trolltech.com/trademarks.html">Trademarks</a> <td align=right><div align=right>Qt version 3.0.2</div> </table></div></address></body> </html>