porting.html

来自「QT 下载资料仅供参考」· HTML 代码 · 共 780 行 · 第 1/3 页

HTML
780
字号
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><!-- /home/reggie/tmp/qt-3.0-reggie-5401/qt-x11-commercial-3.0.5/doc/porting3.doc:36 --><html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>Porting to Qt 3.x</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&nbsp;Classes</font></a> | <a href="mainclasses.html"><font color="#004faf">Main&nbsp;Classes</font></a> | <a href="annotated.html"><font color="#004faf">Annotated</font></a> | <a href="groups.html"><font color="#004faf">Grouped&nbsp;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>Porting to Qt 3.x</h1> <p> This document describes porting applications from Qt 2.x to Qt 3.x. <p> If you haven't yet made the decision about porting, or are unsureabout whether it is worth it, take a look at the <a href="keyfeatures30.html">key features</a> offered by Qt 3.x.<p> The Qt 3.x series is not binary compatible with the 2.x series. Thismeans programs compiled for Qt 2.x must be recompiled to work with Qt3.x.  Qt 3.x is also not completely <em>source</em> compatible with 2.x,however all points of incompatibility cause compiler errors orrun-time messages (rather than mysterious results).  Qt 3.x includesmany additional features and discards obsolete functionality. Portingfrom Qt 2.x to Qt 3.x is straightforward, and once completed makes the considerable additional power and flexibility of Qt 3.x availablefor use in your applications.<p> To port code from Qt 2.x to Qt 3.x:<p> <ol type=1><li> Briefly read the porting notes below to get an idea of what to expect.<li> Be sure your code compiles and runs well on all your target platformswith Qt 2.x.<li> Recompile with Qt 3.x.  For each error, search below for relatedidentifiers (e.g. function names, class names). This document mentions all relevant identifiers to help you get the informationyou need at the cost of being a little verbose.<li> If you get stuck, ask on the <a href="http://qt-interest.trolltech.com/">qt-interest</a> mailing list, or Trolltech Technical Support ifyou're a registered licensee.</ol><p> Table of contents:<p> <!-- toc --><ul><li><a href="#1"> Link errors on Windows</a><li><a href="#2"> Header file inclusion changes</a><li><a href="#3"> Namespace</a><li><a href="#4"> Removed Functions</a><li><a href="#5"> Obsoleted Functions</a><li><a href="#6"> Collection Class Renaming</a><li><a href="#7"> QButtonGroup</a><li><a href="#8"> QDate</a><li><a href="#9"> QFont</a><li><a href="#10"> QInputDialog</a><li><a href="#11"> QLayout and Other Abstract Layout Classes</a><li><a href="#12"> QMultiLineEdit</a><li><a href="#13"> QPrinter</a><li><a href="#14"> QRegExp</a><ul><li><a href="#14-1"> New special characters</a><li><a href="#14-2"> QRegExp::operator=()</a><li><a href="#14-3"> QRegExp::match()</a><li><a href="#14-4"> QRegExp::find()</a><li><a href="#14-5"> QString::findRev() and QString::contains()</a><li><a href="#14-6"> QString::replace()</a></ul><li><a href="#15"> QSemiModal </a><li><a href="#16"> QSortedList</a><li><a href="#17"> QTableView</a><li><a href="#18"> QToolButton</a><li><a href="#19"> QTextStream</a><li><a href="#20"> QTranslator</a><li><a href="#21"> QWidget</a><li><a href="#22"> QXml Classes</a><ul><li><a href="#22-1"> QXmlInputSource</a><li><a href="#22-2"> QXmlLocator</a></ul><li><a href="#23"> Asynchronous I/O Classes</a><li><a href="#24"> Transparent widgets</a><li><a href="#25"> Bezier Curves</a><li><a href="#26"> Locale-aware String Comparisons in QIconView, QListBox,QListView and QTable</a></ul><!-- endtoc --><p> <a name="Linkerrors"></a><h2> Link errors on Windows</h2><a name="1"></a><p> On Windows, originally in Qt 2.x, the default configuration of the Qtlibrary is static. If you just use the default configuration youdon't need to set certain preprocessor defines.  In Qt 3.0, thedefault configuration of the Qt library is to build it as a sharedlibrary, therefore the preprocessor define <tt>QT_DLL</tt> is needed.<p> If you use tmake with Qt 2.x, and now use qmake with Qt 3.x, then thecause of the problem is with the project file. In the project file,there is usually line that looks like:<p> <tt>CONFIG</tt> = ...<p> this should be changed to <p> <tt>CONFIG</tt> += ...<p> so that qmake can look at the configuration that Qt was built with andset any relevant preprocessor defines in the makefile.<p> <a name="Headers"></a><h2> Header file inclusion changes</h2><a name="2"></a><p> Qt 3.x remove some unnecessary nested #include directives fromheader files. This speeds up compilation when you don't need thosenested header files. But in some cases you will find you need to addan extra #include to your files.<p> For example, if you get a message about <a href="qstringlist.html">QStringList</a> or its functionsnot being defined, then add <tt>#include &lt;qstringlist.h&gt;</tt> atthe top of the file giving the error.<p> Header files that you might need to add #include directives for include:<ul><li> <tt>&lt;qcursor.h&gt;</tt><li> <tt>&lt;qpainter.h&gt;</tt><li> <tt>&lt;qpen.h&gt;</tt><li> <tt>&lt;qstringlist.h&gt;</tt><li> <tt>&lt;qregexp.h&gt;</tt><li> <tt>&lt;qstrlist.h&gt;</tt><li> <tt>&lt;qstyle.h&gt;</tt><li> <tt>&lt;qvaluelist.h&gt;</tt></ul><p> <h2> Namespace</h2><a name="3"></a><p> Qt 3.x is namespace clean.  A few global identifiers that had beenleft in Qt 2.x have been discarded.<p> Enumeration <a href="qt.html#CursorShape-enum">Qt::CursorShape</a> and its values are now part of thespecial <a href="qt.html">Qt</a> class defined in qnamespace.h. If you get compilationerrors about these being missing (unlikely, since most of your code willbe in classes that inherit from the Qt namespace class), then applythe following changes:<p> <ul><li> <tt>QCursorShape</tt> becomes <a href="qt.html#CursorShape-enum">Qt::CursorShape</a><li> <tt>ArrowCursor</tt> becomes <a href="qt.html#CursorShape-enum">Qt::ArrowCursor</a><li> <tt>UpArrowCursor</tt> becomes <a href="qt.html#CursorShape-enum">Qt::UpArrowCursor</a><li> <tt>CrossCursor</tt> becomes <a href="qt.html#CursorShape-enum">Qt::CrossCursor</a><li> <tt>WaitCursor</tt> becomes <a href="qt.html#CursorShape-enum">Qt::WaitCursor</a><li> <tt>IbeamCursor</tt> becomes <a href="qt.html#CursorShape-enum">Qt::IbeamCursor</a><li> <tt>SizeVerCursor</tt> becomes <a href="qt.html#CursorShape-enum">Qt::SizeVerCursor</a><li> <tt>SizeHorCursor</tt> becomes <a href="qt.html#CursorShape-enum">Qt::SizeHorCursor</a><li> <tt>SizeBDiagCursor</tt> becomes <a href="qt.html#CursorShape-enum">Qt::SizeBDiagCursor</a><li> <tt>SizeFDiagCursor</tt> becomes <a href="qt.html#CursorShape-enum">Qt::SizeFDiagCursor</a><li> <tt>SizeAllCursor</tt> becomes <a href="qt.html#CursorShape-enum">Qt::SizeAllCursor</a><li> <tt>BlankCursor</tt> becomes <a href="qt.html#CursorShape-enum">Qt::BlankCursor</a><li> <tt>SplitVCursor</tt> becomes <a href="qt.html#CursorShape-enum">Qt::SplitVCursor</a><li> <tt>SplitHCursor</tt> becomes <a href="qt.html#CursorShape-enum">Qt::SplitHCursor</a><li> <tt>PointingHandCursor</tt> becomes <a href="qt.html#CursorShape-enum">Qt::PointingHandCursor</a><li> <tt>BitmapCursor</tt> becomes <a href="qt.html#CursorShape-enum">Qt::BitmapCursor</a></ul><p> The names of some debugging macro variables have been changed.  We havetried not to break source compatibility as much as possible.  If you observeerror messages on the UNIX console or the Windows debugging stream that werepreviously disabled, please check these macro variables:<p> <ul><li> <tt>DEBUG</tt> becomes <tt>QT_DEBUG</tt><li> <tt>NO_DEBUG</tt> becomes <tt>QT_NO_DEBUG</tt><li> <tt>NO_CHECK</tt> becomes <tt>QT_NO_CHECK</tt><li> <tt>CHECK_STATE</tt> becomes <tt>QT_CHECK_STATE</tt><li> <tt>CHECK_RANGE</tt> becomes <tt>QT_CHECK_RANGE</tt><li> <tt>CHECK_NULL</tt> becomes <tt>QT_CHECK_NULL</tt><li> <tt>CHECK_MATH</tt> becomes <tt>QT_CHECK_MATH</tt></ul><p> The name of some debugging macro functions has been changed as wellbut source compatibility should not be affected if the macro variable<tt>QT_CLEAN_NAMESPACE</tt> is not defined:<p> <ul><li> <tt>ASSERT</tt> becomes <tt>Q_ASSERT</tt><li> <tt>CHECK_PTR</tt> becomes <tt>Q_CHECK_PTR</tt></ul><p> For the record, undocumented macro variables that are not part of the APIhave been changed:<p> <ul><li> <tt>_OS_*_</tt> becomes <tt>Q_OS_*</tt><li> <tt>_WS_*_</tt> becomes <tt>Q_WS_*</tt><li> <tt>_CC_*_</tt> becomes <tt>Q_CC_*</tt></ul><p> <h2> Removed Functions</h2><a name="4"></a><p> All these functions have been removed in Qt 3.x:<ul><li> QFont::charSet()<li> QFont::setCharSet()<li> QMenuBar::setActItem()<li> QMenuBar::setWindowsAltMode()<li> QPainter::drawQuadBezier()<li> QPointArray::quadBezier()<li> QRegExp::find()<li> QSpinBox::downButton()<li> QSpinBox::upButton()<li> QString::basicDirection()<li> QString::visual()<li> QStyle::set...() functions<li> QWidget::setFontPropagation()<li> QWidget::setPalettePropagation()</ul><p> Also, to avoid conflicts with <tt>&lt;iostream&gt;</tt>, the following threeglobal functions have been renamed:<ul><li> setw() (renamed qSetW())<li> setfill() (renamed qSetFill())<li> setprecision() (renamed qSetPrecision())</ul><p> <h2> Obsoleted Functions</h2><a name="5"></a><p> The following functions have been obsoleted in Qt 3.0. Thedocumentation of each of these functions should explain how toreplace them in Qt 3.0.<p> <b>Warning:</b> It is best to consult <a href="http://doc.trolltech.com/3.0/">http://doc.trolltech.com/3.0/</a>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?