mainlyxt-editor-example.html
来自「QT 下载资料仅供参考」· HTML 代码 · 共 131 行
HTML
131 行
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><!-- /home/reggie/tmp/qt-3.0-reggie-5401/qt-x11-commercial-3.0.5/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> <p> This example shows two simple text editors, with most of the programwritten in Xt. One editor is a Qt QMultiLineEdit, the other is anAthena Widgets text widget. They are bound together in an Xt formwidget.<p> <hr><p> 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="x2554"></a> mle-><a href="qtextedit.html#setText">setText</a>(QTEDMSG); } void resizeEvent(QResizeEvent* e ) {<a name="x2556"></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="x2558"></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="x2557"></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> <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 © 2002 <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.5</div></table></div></address></body></html>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?