porting.html

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

HTML
780
字号
rather than the documentation supplied with Qt to obtain the latestinformation regarding obsolete functions and how to replace them innew code.<p> <ul><li> <a href="qaccel.html#keyToString">QAccel::keyToString</a>( <a href="qkeysequence.html">QKeySequence</a> k )<li> <a href="qaccel.html#stringToKey">QAccel::stringToKey</a>( const <a href="qstring.html">QString</a> &amp; s )<li> <a href="qactiongroup.html#insert">QActionGroup::insert</a>( <a href="qaction.html">QAction</a> *a )<li> <a href="qbutton.html#autoResize">QButton::autoResize</a>() const<li> <a href="qbutton.html#setAutoResize">QButton::setAutoResize</a>( bool )<li> <a href="qcanvasitem.html#active">QCanvasItem::active</a>() const<li> <a href="qcanvasitem.html#enabled">QCanvasItem::enabled</a>() const<li> <a href="qcanvasitem.html#selected">QCanvasItem::selected</a>() const<li> <a href="qcanvasitem.html#visible">QCanvasItem::visible</a>() const<li> <a href="qcanvaspixmaparray.html#QCanvasPixmapArray">QCanvasPixmapArray::QCanvasPixmapArray</a>( <a href="qptrlist.html">QPtrList</a>&lt;QPixmap&gt; list, QPtrList&lt;QPoint&gt; hotspots )<li> <a href="qcanvaspixmaparray.html#operator!">QCanvasPixmapArray::operator!</a>()<li> <a href="qcolorgroup.html#QColorGroup">QColorGroup::QColorGroup</a>( const <a href="qcolor.html">QColor</a> &amp; foreground, const QColor &amp; background, const QColor &amp; light, const QColor &amp; dark, const QColor &amp; mid, const QColor &amp; text, const QColor &amp; base )<li> <a href="qcombobox.html#autoResize">QComboBox::autoResize</a>() const<li> <a href="qcombobox.html#setAutoResize">QComboBox::setAutoResize</a>( bool )<li> <a href="qdate.html#dayName">QDate::dayName</a>( int weekday )<li> <a href="qdate.html#monthName">QDate::monthName</a>( int month )<li> <a href="qdir.html#encodedEntryList">QDir::encodedEntryList</a>( const <a href="qstring.html">QString</a> &amp; nameFilter, int filterSpec = DefaultFilter, int sortSpec = DefaultSort ) const<li> QDir::encodedEntryList( int filterSpec = DefaultFilter, int sortSpec = DefaultSort ) const<li> <a href="qdockwindow.html#isHorizontalStretchable">QDockWindow::isHorizontalStretchable</a>() const<li> <a href="qdockwindow.html#isVerticalStretchable">QDockWindow::isVerticalStretchable</a>() const<li> <a href="qdockwindow.html#setHorizontalStretchable">QDockWindow::setHorizontalStretchable</a>( bool b )<li> <a href="qdockwindow.html#setVerticalStretchable">QDockWindow::setVerticalStretchable</a>( bool b )<li> <a href="qfont.html#defaultFont">QFont::defaultFont</a>()<li> <a href="qfont.html#setDefaultFont">QFont::setDefaultFont</a>( const <a href="qfont.html">QFont</a> &amp; f )<li> <a href="qfont.html#setPixelSizeFloat">QFont::setPixelSizeFloat</a>( float pixelSize )<li> <a href="qfontdatabase.html#bold">QFontDatabase::bold</a>( const QString &amp; family, const QString &amp; style, const <a href="qstring.html">QString</a> &amp; ) const<li> <a href="qfontdatabase.html#families">QFontDatabase::families</a>( bool ) const<li> <a href="qfontdatabase.html#font">QFontDatabase::font</a>( const QString &amp; familyName, const QString &amp; style, int pointSize, const QString &amp; )<li> <a href="qfontdatabase.html#isBitmapScalable">QFontDatabase::isBitmapScalable</a>( const QString &amp; family, const QString &amp; style, const QString &amp; ) const<li> <a href="qfontdatabase.html#isFixedPitch">QFontDatabase::isFixedPitch</a>( const QString &amp; family, const QString &amp; style, const QString &amp; ) const<li> <a href="qfontdatabase.html#isScalable">QFontDatabase::isScalable</a>( const QString &amp; family, const QString &amp; style, const QString &amp; ) const<li> <a href="qfontdatabase.html#isSmoothlyScalable">QFontDatabase::isSmoothlyScalable</a>( const QString &amp; family, const QString &amp; style, const QString &amp; ) const<li> <a href="qfontdatabase.html#italic">QFontDatabase::italic</a>( const <a href="qstring.html">QString</a> &amp; family, const QString &amp; style, const QString &amp; ) const<li> <a href="qfontdatabase.html#pointSizes">QFontDatabase::pointSizes</a>( const QString &amp; family, const QString &amp; style, const QString &amp; )<li> <a href="qfontdatabase.html#smoothSizes">QFontDatabase::smoothSizes</a>( const QString &amp; family, const QString &amp; style, const QString &amp; )<li> <a href="qfontdatabase.html#styles">QFontDatabase::styles</a>( const QString &amp; family, const QString &amp; ) const<li> <a href="qfontdatabase.html#weight">QFontDatabase::weight</a>( const QString &amp; family, const QString &amp; style, const QString &amp; ) const<li> <a href="qlabel.html#autoResize">QLabel::autoResize</a>() const<li> <a href="qlabel.html#setAutoResize">QLabel::setAutoResize</a>( bool enable )<li> <a href="qlineedit.html#cursorLeft">QLineEdit::cursorLeft</a>( bool mark, int steps = 1 )<li> <a href="qlineedit.html#cursorRight">QLineEdit::cursorRight</a>( bool mark, int steps = 1 )<li> <a href="qlineedit.html#hasMarkedText">QLineEdit::hasMarkedText</a>() const<li> <a href="qlineedit.html#markedText">QLineEdit::markedText</a>() const<li> <a href="qlineedit.html#repaintArea">QLineEdit::repaintArea</a>( int, int )<li> <a href="qlistbox.html#cellHeight">QListBox::cellHeight</a>( int i ) const<li> QListBox::cellHeight() const<li> <a href="qlistbox.html#cellWidth">QListBox::cellWidth</a>() const<li> <a href="qlistbox.html#findItem">QListBox::findItem</a>( int yPos ) const<li> <a href="qlistbox.html#inSort">QListBox::inSort</a>( const <a href="qlistboxitem.html">QListBoxItem</a> *lbi )<li> QListBox::inSort( const <a href="qstring.html">QString</a> &amp; text )<li> <a href="qlistbox.html#itemYPos">QListBox::itemYPos</a>( int index, int *yPos ) const<li> <a href="qlistbox.html#numCols">QListBox::numCols</a>() const<li> <a href="qlistbox.html#totalHeight">QListBox::totalHeight</a>() const<li> <a href="qlistbox.html#totalWidth">QListBox::totalWidth</a>() const<li> <a href="qlistboxitem.html#current">QListBoxItem::current</a>() const<li> <a href="qlistboxitem.html#selected">QListBoxItem::selected</a>() const<li> <a href="qlistview.html#removeItem">QListView::removeItem</a>( <a href="qlistviewitem.html">QListViewItem</a> *item )<li> <a href="qlistviewitem.html#removeItem">QListViewItem::removeItem</a>( QListViewItem *item )<li> <a href="qmainwindow.html#addToolBar">QMainWindow::addToolBar</a>( <a href="qdockwindow.html">QDockWindow</a> *, Dock = DockTop, bool newLine = FALSE )<li> QMainWindow::addToolBar( QDockWindow *, const QString &amp; label, Dock = DockTop, bool newLine = FALSE )<li> <a href="qmainwindow.html#lineUpToolBars">QMainWindow::lineUpToolBars</a>( bool keepNewLines = FALSE )<li> <a href="qmainwindow.html#moveToolBar">QMainWindow::moveToolBar</a>( QDockWindow *, Dock = DockTop )<li> QMainWindow::moveToolBar( QDockWindow *, Dock, bool nl, int index, int extraOffset = -1 )<li> <a href="qmainwindow.html#removeToolBar">QMainWindow::removeToolBar</a>( QDockWindow *)<li> <a href="qmainwindow.html#setToolBarsMovable">QMainWindow::setToolBarsMovable</a>( bool )<li> <a href="qmainwindow.html#toolBarPositionChanged">QMainWindow::toolBarPositionChanged</a>( <a href="qtoolbar.html">QToolBar</a> *)<li> <a href="qmainwindow.html#toolBarsMovable">QMainWindow::toolBarsMovable</a>() const<li> <a href="qmessagebox.html#message">QMessageBox::message</a>( const <a href="qstring.html">QString</a> &amp; caption, const QString &amp; text, const QString &amp; buttonText = <a href="qstring.html#QString-null">QString::null</a>, <a href="qwidget.html">QWidget</a> *parent = 0, const char *= 0 )<li> <a href="qmessagebox.html#query">QMessageBox::query</a>( const QString &amp; caption, const QString &amp; text, const QString &amp; yesButtonText = QString::null, const QString &amp; noButtonText = QString::null, QWidget *parent = 0, const char *= 0 )<li> <a href="qmessagebox.html#standardIcon">QMessageBox::standardIcon</a>( Icon icon, GUIStyle style )<li> <a href="qpalette.html#normal">QPalette::normal</a>()<li> <a href="qregexp.html#match">QRegExp::match</a>( const QString &amp; str, int index = 0, int *len = 0, bool indexIsStart = TRUE ) const<li> <a href="qscrollview.html#childIsVisible">QScrollView::childIsVisible</a>( QWidget *child )<li> <a href="qscrollview.html#showChild">QScrollView::showChild</a>( QWidget *child, bool show = TRUE )<li> <a href="qsignal.html#block">QSignal::block</a>( bool b )<li> <a href="qsignal.html#isBlocked">QSignal::isBlocked</a>() const<li> <a href="qsignal.html#parameter">QSignal::parameter</a>() const<li> <a href="qsignal.html#setParameter">QSignal::setParameter</a>( int value )<li> <a href="qsimplerichtext.html#draw">QSimpleRichText::draw</a>( <a href="qpainter.html">QPainter</a> *p, int x, int y, const <a href="qregion.html">QRegion</a> &amp; clipRegion, const <a href="qcolorgroup.html">QColorGroup</a> &amp; cg, const <a href="qbrush.html">QBrush</a> *paper = 0 ) const<li> <a href="qstring.html#ascii">QString::ascii</a>() const<li> <a href="qstring.html#data">QString::data</a>() const<li> <a href="qstring.html#setExpand">QString::setExpand</a>( uint index, <a href="qchar.html">QChar</a> c )<li> <a href="qstyle.html#defaultFrameWidth">QStyle::defaultFrameWidth</a>() const<li> <a href="qstyle.html#scrollBarExtent">QStyle::scrollBarExtent</a>() const<li> <a href="qstyle.html#tabbarMetrics">QStyle::tabbarMetrics</a>( const <a href="qwidget.html">QWidget</a> *t, int &amp; hf, int &amp; vf, int &amp; ov ) const<li> <a href="qtabdialog.html#isTabEnabled">QTabDialog::isTabEnabled</a>( const char *name ) const<li> <a href="qtabdialog.html#selected">QTabDialog::selected</a>( const <a href="qstring.html">QString</a> &amp; )<li> QTabDialog::selected( const QString &amp; tabLabel )<li> <a href="qtabdialog.html#setTabEnabled">QTabDialog::setTabEnabled</a>( const char *name, bool enable )<li> <a href="qtextstream.html#QTextStream">QTextStream::QTextStream</a>( QString &amp; str, int filemode )<li> <a href="qtoolbar.html#QToolBar">QToolBar::QToolBar</a>( const QString &amp; label, <a href="qmainwindow.html">QMainWindow</a> *, ToolBarDock = DockTop, bool newLine = FALSE, const char *name = 0 )<li> <a href="qtoolbutton.html#iconSet">QToolButton::iconSet</a>( bool on ) const<li> <a href="qtoolbutton.html#offIconSet">QToolButton::offIconSet</a>() const<li> <a href="qtoolbutton.html#onIconSet">QToolButton::onIconSet</a>() const<li> <a href="qtoolbutton.html#setIconSet">QToolButton::setIconSet</a>( const <a href="qiconset.html">QIconSet</a> &amp; set, bool on )<li> <a href="qtoolbutton.html#setOffIconSet">QToolButton::setOffIconSet</a>( const QIconSet &amp; )<li> <a href="qtoolbutton.html#setOnIconSet">QToolButton::setOnIconSet</a>( const QIconSet &amp; )<li> <a href="qtooltip.html#enabled">QToolTip::enabled</a>()<li> <a href="qtooltip.html#setEnabled">QToolTip::setEnabled</a>( bool enable )<li> <a href="qtranslator.html#find">QTranslator::find</a>( const char *context, const char *sourceText, const char *comment = 0 ) const<li> <a href="qtranslator.html#insert">QTranslator::insert</a>( const char *context, const char *sourceText, const <a href="qstring.html">QString</a> &amp; translation )<li> <a href="qtranslator.html#remove">QTranslator::remove</a>( const char *context, const char *sourceText )<li> <a href="quridrag.html#setFilenames">QUriDrag::setFilenames</a>( const <a href="qstringlist.html">QStringList</a> &amp; fnames )<li> <a href="qwidget.html#backgroundColor">QWidget::backgroundColor</a>() const<li> <a href="qwidget.html#backgroundPixmap">QWidget::backgroundPixmap</a>() const<li> <a href="qwidget.html#iconify">QWidget::iconify</a>()<li> <a href="qwidget.html#setBackgroundColor">QWidget::setBackgroundColor</a>( const <a href="qcolor.html">QColor</a> &amp; c )<li> <a href="qwidget.html#setBackgroundPixmap">QWidget::setBackgroundPixmap</a>( const <a href="qpixmap.html">QPixmap</a> &amp; pm )<li> <a href="qwidget.html#setFont">QWidget::setFont</a>( const <a href="qfont.html">QFont</a> &amp; f, bool )<li> <a href="qwidget.html#setPalette">QWidget::setPalette</a>( const <a href="qpalette.html">QPalette</a> &amp; p, bool )<li> <a href="qwizard.html#setFinish">QWizard::setFinish</a>( <a href="qwidget.html">QWidget</a> *, bool )<li> <a href="qxmlinputsource.html#QXmlInputSource">QXmlInputSource::QXmlInputSource</a>( <a href="qfile.html">QFile</a> &amp; file )<li> QXmlInputSource::QXmlInputSource( <a href="qtextstream.html">QTextStream</a> &amp; stream )<li> <a href="qxmlreader.html#parse">QXmlReader::parse</a>( const <a href="qxmlinputsource.html">QXmlInputSource</a> &amp; input )</ul><p> Additionally, these preprocessor directives have been removed:<p> <ul><li> <tt>#define strlen qstrlen</tt><li> <tt>#define strcpy qstrcpy</tt><li> <tt>#define strcmp qstrcmp</tt><li> <tt>#define strncmp qstrncmp</tt><li> <tt>#define stricmp qstricmp</tt><li> <tt>#define strnicmp qstrnicmp</tt></ul><p> See the changes-3.0.0 document for an explanation of why this had to be done.You might have been relying on the non-portable and unpredictable behaviorresulting from these directives. We strongly recommend that you either makeuse of the safe qstr* variants directly or ensure that no 0 pointer ispassed to the standard C functions in your code base.<p> <h2> Collection Class Renaming</h2><a name="6"></a><p> The classes QArray, QCollection, QList, QListIterator, QQueue, QStackand QVector have been renamed. To ease porting, the old names and theold header-file names are still supported.<p> <center><table cellpadding="4" cellspacing="2" border="0"><tr bgcolor="#a2c511"> <th valign="top">Old Name <th valign="top">New Name <th valign="top">New Header File<tr bgcolor="#f0f0f0"> <td valign="top">QArray <td valign="top"><a href="qmemarray.html">QMemArray</a> <td valign="top"><tt>&lt;qmemarray.h&gt;</tt><tr bgcolor="#d0d0d0"> <td valign="top">QCollection <td valign="top"><a href="qptrcollection.html">QPtrCollection</a> <td valign="top"><tt>&lt;qptrcollection.h&gt;</tt><tr bgcolor="#f0f0f0"> <td valign="top">QList <td valign="top"><a href="qptrlist.html">QPtrList</a> <td valign="top"><tt>&lt;qptrlist.h&gt;</tt><tr bgcolor="#d0d0d0"> <td valign="top">QListIterator <td valign="top"><a href="qptrlistiterator.html">QPtrListIterator</a> <td valign="top"><tt>&lt;qptrlist.h&gt;</tt><tr bgcolor="#f0f0f0"> <td valign="top">QQueue <td valign="top"><a href="qptrqueue.html">QPtrQueue</a> <td valign="top"><tt>&lt;qptrqueue.h&gt;</tt><tr bgcolor="#d0d0d0"> <td valign="top">QStack <td valign="top"><a href="qptrstack.html">QPtrStack</a> <td valign="top"><tt>&lt;qptrstack.h&gt;</tt><tr bgcolor="#f0f0f0"> <td valign="top">QVector <td valign="top"><a href="qptrvector.html">QPtrVector</a> <td valign="top"><tt>&lt;qptrvector.h&gt;</tt></table></center><p> <h2> <a href="qbuttongroup.html">QButtonGroup</a></h2><a name="7"></a><p> In Qt 2.x, the function <a href="qbuttongroup.html#selected">QButtonGroup::selected</a>() returns the selected<em>radio</em> button (<a href="qradiobutton.html">QRadioButton</a>). In Qt 3.0, it returns the selected <em>toggle</em> button (<a href="qbutton.html#toggleButton-prop">QButton::toggleButton</a>), a more general concept.This might affect programs that use QButtonGroups that contain amixture of radio buttons and non-radio (e.g. <a href="qcheckbox.html">QCheckBox</a>) toggle buttons.<p> <h2> <a href="qdate.html">QDate</a></h2><a name="8"></a><p> Two QDate member functions that were virtual in Qt 2.0 are not virtualin Qt 3.0. This is only relevant if you subclassed QDate andreimplemented these functions:<p> <ul><li> <a href="qstring.html">QString</a> <a href="qdate.html#monthName">QDate::monthName</a>( int month ) const<li> QString <a href="qdate.html#dayName">QDate::dayName</a>( int weekday ) const</ul><p> In addition to no longer being virtual, QDate::monthName() andQDate::dayName() have been renamed <a href="qdate.html#shortMonthName">QDate::shortMonthName</a>() and<a href="qdate.html#shortDayName">QDate::shortDayName</a>() and have been made static (as they should hadbeen in the first place). The old names are still provided for sourcecompatibility.<p> <h2> <a href="qfont.html">QFont</a></h2><a name="9"></a><p> The internals of QFont have changed significantly between Qt 2.2 andQt 3.0, to give better Unicode support and to make developinginternationalized applications easier. The original API has beenpreserved with minimal changes. The CharSet enum and its relatedfunctions have disappeared. This is because Qt now handles all charsetrelated issues internally, and removes this burden from the developer.<p> If you used the CharSet enum or its related functions, e.gQFont::charSet() or QFont::setCharSet(), just remove them from yourcode. There are a few functions that took a QFont::CharSet as aparameter; in these cases simply remove the charset from theparameter list.<p> <h2> <a href="qinputdialog.html">QInputDialog</a></h2><a name="10"></a><p> The two static getText(...) methods in QInputDialog have been merged. The <tt>echo</tt> parameter is the third parameter and defaults to QLineEdit::Normal. <p> If you used calls to <a href="qinputdialog.html#getText">QInputDialog::getText</a>(...) that provided more than the first two required parameters you will must add a value for the <tt>echo</tt> parameter.<p> <h2> <a href="qlayout.html">QLayout</a> and Other Abstract Layout Classes</h2><a name="11"></a><p> The definitions of <a href="qglayoutiterator.html">QGLayoutIterator</a>, <a href="qlayout.html">QLayout</a>, <a href="qlayoutitem.html">QLayoutItem</a>, <a href="qlayoutiterator.html">QLayoutIterator</a>, <a href="qspaceritem.html">QSpacerItem</a> and <a href="qwidgetitem.html">QWidgetItem</a> have been moved from <tt>&lt;qabstractlayout.h&gt;</tt> to <tt>&lt;qlayout.h&gt;</tt>. The header <tt>&lt;qabstractlayout.h&gt;</tt> now includes <tt>&lt;qlayout.h&gt;</tt> for compatibility. Itmight be removed in a future version.<p> <h2> QMultiLineEdit</h2><a name="12"></a><p> The QMultiLineEdit was a simple editor widget in previous Qt versions.Since Qt 3.0 includes a new richtext engine, which also supportsediting, QMultiLineEdit is obsolete. For the sake of compatibilityQMultiLineEdit is still provided. It is now a subclass of <a href="qtextedit.html">QTextEdit</a>which wraps the old QMultiLineEdit so that it is mostly sourcecompatible to keep old applications working.<p> For new applications and when maintaining existing applications werecommend that you use QTextEdit instead of QMultiLineEdit whereverpossible.<p> Although most of the old QMultiLineEdit API is still available, thereis one important difference. The old QMultiLineEdit operated in termsof lines, whereas QTextEdit operates in terms of paragraphs. This isbecause lines change all the time during wordwrap, whereas paragraphsremain paragraphs. The consequence of this change is that functionswhich previously operated on lines, e.g. numLines(), textLine(), etc.,now work on paragraphs.<p> Also the function getString() has been removed since itpublished the internal data structure.<p> In most cases, applications that used QMultiLineEdit will continue towork without problems. Applications that worked in terms of lines mayrequire some porting.<p> The source code for the old 2.x version of QMultiLineEdit can be foundin <tt>$QTDIR/src/attic/qtmultilineedit.h/cpp</tt>. Note that the class hasbeen renamed to QtMultiLineEdit to avoid name clashes. If you reallyneed to keep compatibility with the old QMultiLineEdit, simply includethis class in your project and rename QMultiLineEdit toQtMultiLineEdit throughout.<p> <h2> <a href="qprinter.html">QPrinter</a></h2><a name="13"></a><p> QPrinter has undergone some changes, to make it more flexible andto ensure it has the same runtime behaviour on both Unix and Windows. In 2.x,QPrinter behaved differently on Windows and Unix, when using viewtransformations on the <a href="qpainter.html">QPainter</a>. This has changed now, and QPrinterbehaves consistently across all platforms. A compatibilty mode has beenadded that forces the old behaviour, to ease porting from Qt 2.xto Qt 3.x. This compatibilty mode can be enabled by passing theQPrinter::Compatible flag to the QPrinter constructor.<p> On X11, QPrinter used to generate encapsulated postscript whenfullPage() was TRUE and only one page was printed. This does nothappen by default anymore, providing a more consistent printing output.<p> <h2> <a href="qregexp.html">QRegExp</a></h2><a name="14"></a><p> The <a href="qregexp.html">QRegExp</a> class has been rewritten to support many of the features of Perlregular expressions.  Both the <a href="qregexp.html#regular-expression">regular expression</a> syntax and the QRegExpinterface have been modified.<p> Be also aware that <tt>&lt;qregexp.h&gt;</tt> is no longer includedautomatically when you include <tt>&lt;qstringlist.h&gt;</tt>. See<a href="#Headers">above</a> for details.<p> <p> <h3> New special characters</h3><a name="14-1"></a><p> There are five new special characters: <tt>(</tt>, <tt>)</tt>, <tt>{</tt>,<tt>|</tt> and <tt>}</tt> (parentheses, braces and pipe). When porting oldregular expressions, you must add <tt>&#92;</tt> (backslash) in front of anyof these (actually, <tt>&#92;&#92;</tt> in C++ strings), unless it is alreadythere.<p> Example: Old code like<pre>    <a href="qregexp.html">QRegExp</a> rx( "([0-9|]*\\)" );        // works in Qt 2.x</pre> should be converted into<pre>    <a href="qregexp.html">QRegExp</a> rx( "\\([0-9\\|]*\\)" );      // works in Qt 2.x and 3.x</pre>

⌨️ 快捷键说明

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