porting.html

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

HTML
780
字号
 (Within character classes, the backslash is not necessary in front of certaincharacters, e.g. <tt>|</tt>, but it doesn't hurt.)<p> Wildcard patterns need no conversion.  Here are two examples:<pre>    <a href="qregexp.html">QRegExp</a> wild( "(*.*)" );    wild.<a href="qregexp.html#setWildcard">setWildcard</a>( TRUE );</pre> <pre>    // TRUE as third argument means wildcard    <a href="qregexp.html">QRegExp</a> wild( "(*.*)", FALSE, TRUE );</pre> However, when they are used, make sure to use <a href="qregexp.html#exactMatch">QRegExp::exactMatch</a>()rather than the obsolete <a href="qregexp.html#match">QRegExp::match</a>(). QRegExp::match(), likeQRegExp::find(), tries to find a match somewhere in the targetstring, while QRegExp::exactMatch() tries to match the whole targetstring.<p> <h3> <a href="qregexp.html#operator-eq">QRegExp::operator=</a>()</h3><a name="14-2"></a><p> This function has been replaced by <a href="qregexp.html#setPattern">QRegExp::setPattern</a>() in Qt 2.2.Old code such as<pre>    <a href="qregexp.html">QRegExp</a> rx( "alpha" );    rx.<a href="qregexp.html#setCaseSensitive">setCaseSensitive</a>( FALSE );    rx.<a href="qregexp.html#setWildcard">setWildcard</a>( TRUE );    rx = "beta";</pre> still compiles with Qt 3, but produces a different result (the case sensitivityand wildcard options are forgotten). This way,<pre>    rx = "beta";</pre> is the same as<pre>    rx = QRegExp( "beta" );</pre> which is what one expects.<p> <h3> QRegExp::match()</h3><a name="14-3"></a><p> The following function is now obsolete, as it has an unwieldyparameter list and was poorly named:<ul><li> bool <a href="qregexp.html#match">QRegExp::match</a>( const <a href="qstring.html">QString</a> &amp; str, int index = 0,int * len = 0, bool indexIsStart = TRUE ) const</ul>It will be removed in a future version of Qt. Its <a href="qregexp.html#match">documentation</a> explains how to replace it.<p> <h3> QRegExp::find()</h3><a name="14-4"></a><p> This function was removed, after a brief appearance in Qt 2.2.  Itsname clashed with <a href="qstring.html#find">QString::find</a>().  Use <a href="qregexp.html#search">QRegExp::search</a>() or <a href="qstring.html#find">QString::find</a>() instead.<p> <h3> <a href="qstring.html#findRev">QString::findRev</a>() and <a href="qstring.html#contains">QString::contains</a>()</h3><a name="14-5"></a><p> <a href="qstring.html#findRev">QString::findRev</a>()'s and <a href="qstring.html#contains">QString::contains</a>()'s semantics have changedbetween 2.0 and 3.0 to be more consistent with the other overloads.<p> For example,<pre>    QString( "" ).contains( QRegExp("") )</pre> returns 1 in Qt 2.0; it returns 0 in Qt 3.0. Also, "^" now really meansstart of input, so<pre>    QString( "Heisan Hoppsan" ).contains( QRegExp("^.*$") )</pre> returns 1, not 13 or 14.<p> This change affect very few existing programs.<p> <h3> <a href="qstring.html#replace">QString::replace</a>()</h3><a name="14-6"></a><p> With Qt 1.0 and 2.0, a <a href="qstring.html">QString</a> is converted implicitly into a <a href="qregexp.html">QRegExp</a>as the first argument to QString::replace():<pre>    <a href="qstring.html">QString</a> text = fetch_it_from_somewhere();    text.<a href="qstring.html#replace">replace</a>( QString("[A-Z]+"), "" );</pre> With Qt 3.0, the compiler gives an error. The solution is to use aQRegExp cast:<pre>    text.replace( QRegExp("[A-Z]+"), "" );</pre> This change makes it possible to introduce aQString::replace(QString, QString) overload in a future version of Qtwithout breaking source compatibility.<p> <h2> QSemiModal </h2><a name="15"></a><p> The QSemiModal class is now obsolete. You should call show() on amodal dialog instead.<p> <h2> QSortedList</h2><a name="16"></a><p> The QSortedList class is now obsolete. Consider using a <a href="qdict.html">QDict</a>, a <a href="qmap.html">QMap</a>or a plain <a href="qptrlist.html">QPtrList</a> instead.<p> <h2> QTableView</h2><a name="17"></a><p> The QTableView class has been obsoleted and is no longer a part of theQt API. Either use the powerful <a href="qtable.html">QTable</a> class or the simplistic<a href="qgridview.html">QGridView</a> in any new code you create. If you really need the old tableview for compatibility you can find it in <tt>$QTDIR/src/attic/qttableview.{cpp,h}</tt>. Note that the class has beenrenamed from QTableView to QtTableView to avoid name clashes. To useit, simply include it in your project and rename QTableView toQtTableView throughout.<p> <h2> <a href="qtoolbutton.html">QToolButton</a></h2><a name="18"></a><p> The <a href="qtoolbutton.html">QToolButton</a> class used to distinguish between "on" and "off"icons. In 3.0, this mechanism was moved into the <a href="qiconset.html">QIconSet</a> class(see <a href="qiconset.html#State-enum">QIconSet::State</a>).<p> The old <a href="qtoolbutton.html#onIconSet-prop">QToolButton::onIconSet</a> and <a href="qtoolbutton.html#offIconSet-prop">QToolButton::offIconSet</a>properties are still provided so that old source will compile, buttheir semantics have changed: they are now synonyms for <a href="qtoolbutton.html#iconSet-prop">QToolButton::iconSet</a>. If you used that distinction in Qt 2.x, you willneed to adjust your code to use the <a href="qiconset.html">QIconSet</a> On/Off mechanism.<p> Likewise, the <em>on</em> parameter of these two functions is now ignored:<p> <ul><li> void QToolButton::setIconSet ( const QIconSet &amp; set, bool on )<li> QIconSet QToolButton::iconSet ( bool on ) const</ul><p> These functions are only provided for ease of porting. New codeshould use the following instead:<p> <ul><li> void <a href="qtoolbutton.html#setIconSet">QToolButton::setIconSet</a>( const QIconSet &amp; set )<li> QIconSet <a href="qtoolbutton.html#iconSet">QToolButton::iconSet</a>() const</ul><p> Finally, this function is no longer virtual:<p> <ul><li> void QToolButton::setIconSet( const QIconSet &amp; set, bool on )</ul><p> If you have a class that inherits <a href="qtoolbutton.html">QToolButton</a> and that reimplementsQToolButton::setIconSet(), you should make the signature of thereimplementation agree with the new <a href="qtoolbutton.html#setIconSet">QToolButton::setIconSet</a>(),a virtual function.<p> <h2> <a href="qtextstream.html">QTextStream</a></h2><a name="19"></a><p> The global QTextStream manipulators setw(), setfill() and setprecison()were renamed to qSetW(), qSetFill() and qSetPrecision() to avoid conflictswith <tt>&lt;iostream.h&gt;</tt>. If you used them, you must rename the occurrences tothe new names.<p> <h2> <a href="qtranslator.html">QTranslator</a></h2><a name="20"></a><p> The <a href="qtranslator.html">QTranslator</a> class was extended in Qt 2.2, and these extensionslead to a new interface.  This interface is used mainly by translationtools (for example, <a href="linguist-manual.html">QtLinguist</a>).  For source compatibility, no member function waseffectively removed.  The <a href="qtranslator.html">QTranslator</a> documentation points outwhich functions are obsolete.<p> This function is no longer virtual:<p> <ul><li> <a href="qstring.html">QString</a> <a href="qtranslator.html#find">QTranslator::find</a>( const char * context,const char * sourceText ) const</ul><p> If you have a class that inherits QTranslator and which reimplementsQTranslator::find(), you should reimplement <a href="qtranslator.html#findMessage">QTranslator::findMessage</a>() instead.In fact, find() is now defined in terms of findMessage().  By doing theconversion, you will also gain support for translator comments and for anyfuture extensions.<p> <h2> <a href="qwidget.html">QWidget</a></h2><a name="21"></a><p> <a href="qwidget.html#backgroundColor">QWidget::backgroundColor</a>(), <a href="qwidget.html#setBackgroundColor">QWidget::setBackgroundColor</a>(),<a href="qwidget.html#backgroundPixmap">QWidget::backgroundPixmap</a>() and <a href="qwidget.html#setBackgroundPixmap">QWidget::setBackgroundPixmap</a>() haveoften been the source of much confusion in previous releases. Qt 3.0addresses this by obsoleting these functions and by remplacing themwith eight new functions: <a href="qwidget.html#eraseColor">QWidget::eraseColor</a>(),<a href="qwidget.html#setEraseColor">QWidget::setEraseColor</a>(), <a href="qwidget.html#erasePixmap">QWidget::erasePixmap</a>(),<a href="qwidget.html#setErasePixmap">QWidget::setErasePixmap</a>(), <a href="qwidget.html#paletteBackgroundColor">QWidget::paletteBackgroundColor</a>(),<a href="qwidget.html#setPaletteBackgroundColor">QWidget::setPaletteBackgroundColor</a>(),<a href="qwidget.html#paletteBackgroundPixmap">QWidget::paletteBackgroundPixmap</a>() and<a href="qwidget.html#setPaletteBackgroundPixmap">QWidget::setPaletteBackgroundPixmap</a>(). See their documentation fordetails.<p> <h2> QXml Classes</h2><a name="22"></a><p> <h3> <a href="qxmlinputsource.html">QXmlInputSource</a></h3><a name="22-1"></a><p> The semantics of QXmlInputSource has changed slightly. This changeonly affects code that parses the same data from the same input sourcemultiple times. In such cases you must call<a href="qxmlinputsource.html#reset">QXmlInputSource::reset</a>() before the second call to<a href="qxmlsimplereader.html#parse">QXmlSimpleReader::parse</a>().<p> So code like<pre>    <a href="qxmlinputsource.html">QXmlInputSource</a> source( &amp;xmlFile );    <a href="qxmlsimplereader.html">QXmlSimpleReader</a> reader;    ...    reader.<a href="qxmlsimplereader.html#parse">parse</a>( source );    ...    reader.<a href="qxmlsimplereader.html#parse">parse</a>( source );</pre> must be changed to<pre>    <a href="qxmlinputsource.html">QXmlInputSource</a> source( &amp;xmlFile );    <a href="qxmlsimplereader.html">QXmlSimpleReader</a> reader;    ...    reader.<a href="qxmlsimplereader.html#parse">parse</a>( source );    ...    source.<a href="qxmlinputsource.html#reset">reset</a>();    reader.<a href="qxmlsimplereader.html#parse">parse</a>( source );</pre> <p> <h3> <a href="qxmllocator.html">QXmlLocator</a></h3><a name="22-2"></a><p> Due to some internal changes, it was necessary to clean-up the semantics ofQXmlLocator: this class is now an abstract class. This shouldn't causeany problems, since programmers usually used the QXmlLocator that wasreported by <a href="qxmlcontenthandler.html#setDocumentLocator">QXmlContentHandler::setDocumentLocator</a>(). If you used thisclass in some other way, you must adjust your code to use theQXmlLocator that is reported by theQXmlContentHandler::setDocumentLocator() function.<p> <h2> Asynchronous I/O Classes</h2><a name="23"></a><p> QASyncIO, QDataSink, QDataSource, QIODeviceSource and QDataPump wereused internally in previous versions of Qt, but are not used anymore.They are now obsolete.<p> <h2> Transparent widgets</h2><a name="24"></a><p> In Qt 2.x, the AutoMask property was used to obtain atransparent-looking widget. In general, this approach is slow andprocessor hungry. Qt 3.0 uses the BackgroundOrigin which providesvastly improved performance and more flexibility in most cases. Thefew classes for which the AutoMask property is still the best approachare <a href="qcheckbox.html">QCheckBox</a>, <a href="qcombobox.html">QComboBox</a>, <a href="qpushbutton.html">QPushButton</a>, <a href="qradiobutton.html">QRadioButton</a> and <a href="qtabwidget.html">QTabWidget</a>.<p> <h2> Bezier Curves</h2><a name="25"></a><p> The function names for Bezier curves in <a href="qpainter.html">QPainter</a> and <a href="qpointarray.html">QPointArray</a> havebeen corrected. They now properly reflect their cubic form instead ofa quadratic one. If you have been using eitherQPainter::drawQuadBezier() or QPointArray::quadBezier() you mustreplace these calls with<ul><li> void <a href="qpainter.html#drawCubicBezier">QPainter::drawCubicBezier</a>( const QPointArray &amp;, int index=0 ) and<li> QPointArray <a href="qpointarray.html#cubicBezier">QPointArray::cubicBezier</a>() const</ul>respectively. Neither the arguments nor the resulting curve have changed.<p> <h2> Locale-aware String Comparisons in <a href="qiconview.html">QIconView</a>, <a href="qlistbox.html">QListBox</a>,<a href="qlistview.html">QListView</a> and <a href="qtable.html">QTable</a></h2><a name="26"></a><p> In Qt 2.x, <a href="qstring.html">QString</a> only provided string comparisons using the Unicodevalues of the characters of a string. This is efficient and reliable,but it is not the appropriate order for most languages. For example,French users expect '&eacute;' (e acute) to be treated essentially as'e' and not put after 'z'.<p> In Qt 3.0, <a href="qstring.html#localeAwareCompare">QString::localeAwareCompare</a>() implements locale awarestring comparisions on certain platforms. The classes <a href="qiconview.html">QIconView</a>, <a href="qlistbox.html">QListBox</a>, <a href="qlistview.html">QListView</a> and <a href="qtable.html">QTable</a> now useQString::localeAwareCompare() instead of <a href="qstring.html#compare">QString::compare</a>(). If youwant to control the behaviour yourself you can always reimplement<a href="qiconviewitem.html#compare">QIconViewItem::compare</a>(), <a href="qlistbox.html#text">QListBox::text</a>(), <a href="qlistviewitem.html#compare">QListViewItem::compare</a>()or <a href="qtableitem.html#key">QTableItem::key</a>() as appropriate.<p> <!-- eof --><p><address><hr><div align=center><table width=100% cellspacing=0 border=0><tr><td>Copyright &copy; 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 + -
显示快捷键?