doc/src/porting/porting4.qdoc
changeset 0 1918ee327afb
equal deleted inserted replaced
-1:000000000000 0:1918ee327afb
       
     1 /****************************************************************************
       
     2 **
       
     3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     4 ** All rights reserved.
       
     5 ** Contact: Nokia Corporation (qt-info@nokia.com)
       
     6 **
       
     7 ** This file is part of the documentation of the Qt Toolkit.
       
     8 **
       
     9 ** $QT_BEGIN_LICENSE:LGPL$
       
    10 ** No Commercial Usage
       
    11 ** This file contains pre-release code and may not be distributed.
       
    12 ** You may use this file in accordance with the terms and conditions
       
    13 ** contained in the Technology Preview License Agreement accompanying
       
    14 ** this package.
       
    15 **
       
    16 ** GNU Lesser General Public License Usage
       
    17 ** Alternatively, this file may be used under the terms of the GNU Lesser
       
    18 ** General Public License version 2.1 as published by the Free Software
       
    19 ** Foundation and appearing in the file LICENSE.LGPL included in the
       
    20 ** packaging of this file.  Please review the following information to
       
    21 ** ensure the GNU Lesser General Public License version 2.1 requirements
       
    22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
       
    23 **
       
    24 ** In addition, as a special exception, Nokia gives you certain additional
       
    25 ** rights.  These rights are described in the Nokia Qt LGPL Exception
       
    26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
       
    27 **
       
    28 ** If you have questions regarding the use of this file, please contact
       
    29 ** Nokia at qt-info@nokia.com.
       
    30 **
       
    31 **
       
    32 **
       
    33 **
       
    34 **
       
    35 **
       
    36 **
       
    37 **
       
    38 ** $QT_END_LICENSE$
       
    39 **
       
    40 ****************************************************************************/
       
    41 
       
    42 /*!
       
    43     \group porting
       
    44     \title Porting Guides
       
    45     \brief Guides related to porting Qt applications and libraries.
       
    46     \ingroup best-practices
       
    47 
       
    48     A number of guides and documents are available that cover porting issues,
       
    49     from detailed coverage of API differences between Qt 3 and Qt 4 to
       
    50     platform and tool-specific documentation.
       
    51 
       
    52     \generatelist{related}
       
    53 */
       
    54 
       
    55 /*!
       
    56     \page porting4.html
       
    57     \title Porting to Qt 4
       
    58     \contentspage {Porting Guides}{Contents}
       
    59     \previouspage Porting Guides
       
    60     \nextpage Porting to Qt 4 - Virtual Functions
       
    61     \ingroup porting
       
    62     \brief An overview of issues and techniques to consider when porting from Qt 3 to Qt 4.
       
    63 
       
    64 \omit
       
    65     ### QFileInfo::PermissionSpec -> QFile::Permission(s?)
       
    66     ### refer to porting4-renamedfunctions.qdoc
       
    67     ### QApplication library mutex is gone
       
    68     ### no integral conversion for containers? strings?
       
    69     ### QVector etc. are initialized to 0 by default?
       
    70     ### How to port from Qt 2.3 to Qt 4.
       
    71     ### missing sort() functions?
       
    72     ### QToolTipGroup
       
    73     ### QServerSocket -> Q3ServerSocket
       
    74 
       
    75     ### remove these when the classes are re-ported
       
    76 
       
    77     ### QApplication::eventLoop()
       
    78 
       
    79     \row \o void QCheckListItem::paintCell(QPainter *, const QColorGroup &, int, int, int)\row \o void Q3CheckListItem::paintCell(QPainter *, const QPalette &, int, int, int)
       
    80     \row \o void QCheckListItem::paintFocus(QPainter *, const QColorGroup &, const QRect &) \o void Q3CheckListItem::paintFocus(QPainter *, const QPalette &, const QRect &)
       
    81     \row \o QDataTable: a whole bunch of virtual functions have a different signature
       
    82 
       
    83     <     Function: void QIconViewItem::paintFocus(QPainter *, const QColorGroup &)
       
    84     >     Function: void QIconViewItem::paintFocus(QPainter *, const QPalette &)
       
    85 
       
    86     <     Function: void QIconViewItem::paintItem(QPainter *, const QColorGroup &)
       
    87     >     Function: void QIconViewItem::paintItem(QPainter *, const QPalette &)
       
    88 
       
    89     <     Function: bool QUrlOperator::checkValid()
       
    90 
       
    91     <     Function: void QWSInputMethod::setFont(const QFont &)
       
    92 
       
    93     ### OpenMode or OpenMode
       
    94 
       
    95     ### QWSDecoration
       
    96 \endomit
       
    97 
       
    98     This document describes the process of porting applications from
       
    99     Qt 3 to Qt 4.
       
   100     If you haven't yet made the decision about porting, or are unsure
       
   101     about whether it is worth it, take a look at the \l{What's New in
       
   102     Qt 4}{key features} offered by Qt 4. See also
       
   103     \l{Moving from Qt 3 to Qt 4} for tips on how to write Qt 3 code
       
   104     that is easy to port to Qt 4.
       
   105 
       
   106     \bold{Other porting guides:}
       
   107 
       
   108     \list
       
   109     \o \l{Moving from Qt 3 to Qt 4} \mdash covers some high level topics relevant
       
   110        to developers porting from Qt 3 to Qt 4.
       
   111     \o \l{Porting to Qt 4 - Drag and Drop} \mdash covers differences in the
       
   112        way drag and drop is handled between Qt 3 and Qt 4.
       
   113     \o \l{Porting UI Files to Qt 4} \mdash describes the new format used to
       
   114        describe forms created with \QD.
       
   115     \o \l{Porting to Graphics View} \mdash provides a class-by-class overview
       
   116        of the differences between Qt 3's canvas API and Qt 4's Graphics
       
   117        View framework.
       
   118     \o \l{qt3to4 - The Qt 3 to 4 Porting Tool} \mdash provides an overview
       
   119        of a tool aimed at helping developers start the process of porting an
       
   120        application to Qt 4.
       
   121     \endlist
       
   122 
       
   123     The Qt 4 series is not binary compatible with the 3 series. This
       
   124     means programs compiled for Qt 3 must be recompiled to work with
       
   125     Qt 4. Qt 4 is also not completely \e source compatible with 3,
       
   126     however nearly all points of incompatibility cause compiler
       
   127     errors or run-time messages (rather than mysterious results). Qt
       
   128     4 includes many additional features and discards obsolete
       
   129     functionality. Porting from Qt 3 to Qt 4 requires some effort,
       
   130     but once completed the considerable additional power and
       
   131     flexibility of Qt 4 is available for use in your applications.
       
   132 
       
   133     To port code from Qt 3 to Qt 4:
       
   134 
       
   135     \list 1
       
   136 
       
   137     \o Briefly read the porting notes below to get an idea of what to expect.
       
   138 
       
   139     \o Be sure that your code compiles and runs well on all your target
       
   140        platforms with Qt 3.
       
   141 
       
   142     \o Add the line \c{QT += qt3support} to your \c .pro file if you use
       
   143        \c qmake; otherwise, edit your makefile or project file to
       
   144        link against the Qt3Support library and add \c -DQT3_SUPPORT to your
       
   145        compiler flags. (You might also need to specify other
       
   146        libraries. See \l{What's New in Qt 4} for details.)
       
   147 
       
   148     \o Run the \l qt3to4 porting tool. The tool will go through your
       
   149        source code and adapt it to Qt 4.
       
   150 
       
   151     \o Follow the instructions in the \l{Porting UI Files to Qt 4}
       
   152        page to port Qt Designer files.
       
   153 
       
   154     \o Recompile with Qt 4. For each error, search below for related
       
   155        identifiers (e.g., function names, class names). This document
       
   156        mentions all relevant identifiers to help you get the information
       
   157        you need at the cost of being a little verbose.
       
   158 
       
   159     \endlist
       
   160 
       
   161     The \l qt3to4 porting tool replaces occurrences of Qt 3 classes
       
   162     that don't exist anymore in Qt 4 with the corresponding Qt 3
       
   163     support class; for example, \c QListBox is turned into \c
       
   164     Q3ListBox.
       
   165 
       
   166     At some point, you might want to stop linking against the Qt 3
       
   167     support library (\l{Qt3Support}) and take advantage of Qt 4's
       
   168     new features. The instructions below explain how to do that for
       
   169     each compatibility class.
       
   170 
       
   171     In addition to the Qt3Support classes (such as \c Q3Action, \c
       
   172     Q3ListBox, and \c Q3ValueList), Qt 4 provides compatibility
       
   173     functions when it's possible for an old API to cohabit with the
       
   174     new one. For example, QString provides a
       
   175     QString::simplifyWhiteSpace() compatibility function that's
       
   176     implemented inline and that simply calls QString::simplified().
       
   177     \bold{The compatibility functions are not documented here; instead,
       
   178     they are documented for each class.}
       
   179 
       
   180     If you have the line \c{QT += qt3support} in your \c .pro file, \c
       
   181     qmake will automatically define the \c QT3_SUPPORT symbol, turning
       
   182     on compatibility function support. You can also define the symbol
       
   183     manually (e.g., if you don't want to link against the \c
       
   184     Qt3Support library), or you can define \c QT3_SUPPORT_WARNINGS
       
   185     instead, telling the compiler to emit a warning when a
       
   186     compatibility function is called. (This works only with GCC 3.2+
       
   187     and MSVC 7.)
       
   188 
       
   189     If you get stuck, ask on the
       
   190     \l{http://qt.nokia.com/lists/qt-interest/}{qt-interest}
       
   191     mailing list. If you are a licensed customer, you can also contact
       
   192     Qt's technical support team.
       
   193 
       
   194 \omit
       
   195     ### what to do with slots that aren't slots anymore
       
   196     ### what to do with virtual functions that aren't virtual anymore
       
   197     ### what to do with virtual functions that changed signature
       
   198 \endomit
       
   199 
       
   200 \omit
       
   201     ### <qtl.h> -- stuff that vanished?
       
   202     ### implicit sharing
       
   203     ### uint -> int indexes
       
   204 \endomit
       
   205 
       
   206     Table of contents:
       
   207 
       
   208     \tableofcontents{4}
       
   209 
       
   210 \omit
       
   211     \section1 Header Files
       
   212 
       
   213     ### New style of headers
       
   214 
       
   215     \table
       
   216     \header \o Old header \o New header
       
   217     \row \o \c{<qtl.h>} \o \c{<qalgorithms.h>} or \c{<QtAlgorithms>}
       
   218     \endtable
       
   219 
       
   220     ### Some headers don't include each other anymore...
       
   221 \endomit
       
   222 
       
   223     \section1 Casting and Object Types
       
   224 
       
   225     In Qt 3, it was possible to use the \c qt_cast() function to determine
       
   226     whether instances of QObject subclasses could be safely cast to derived
       
   227     types of those subclasses. For example, if a QFrame instance is passed
       
   228     to a function whose signature specifies a QWidget pointer as its argument,
       
   229     \c qt_cast() could be used to obtain a QFrame pointer so that the
       
   230     instance's functions can be accessed.
       
   231 
       
   232     In Qt 4, much of this functionality is provided by the qobject_cast()
       
   233     function, and additional functions also provide similar functionality for
       
   234     certain non-QObject types:
       
   235 
       
   236     \table
       
   237     \header \o Qt 3 function \o Qt 4 function
       
   238     \row    \o T *qt_cast<T *>(QObject *) \o \l{qobject_cast()}{T *qobject_cast<T *>(QObject *)}
       
   239     \row    \o                            \o \l{qgraphicsitem_cast()}{T qgraphicsitem_cast<T>(QGraphicsItem *)}
       
   240     \row    \o                            \o \l{qstyleoption_cast()}{T qstyleoption_cast<T>(QStyleOption *)}
       
   241     \row    \o                            \o \l{qvariant_cast()}{T qvariant_cast<T>(const QVariant &)}
       
   242     \row    \o                            \o \l{qdbus_cast()}{T qdbus_cast(const QDBusArgument &)}
       
   243     \endtable
       
   244 
       
   245 \omit
       
   246     \section1 Global Functions
       
   247 
       
   248     \table
       
   249     \header \o Qt 3 function \o Qt 4 function
       
   250     \row \o cstrcmp() \o strcmp()
       
   251     \row \o cstrcpy() \o strcpy()
       
   252     \row \o cstrlen() \o strlen()
       
   253     \row \o cstrncmp() \o strncmp()
       
   254     \row \o qmemmove() \o memmove()
       
   255     \endtable
       
   256 
       
   257     qGLVersion() ###
       
   258 
       
   259     copyBlt() ###
       
   260     bitBlt()
       
   261 
       
   262     #ifdef compat classes:
       
   263         * QLayoutIterator
       
   264         * QColorGroup
       
   265         * QMenuItem
       
   266 
       
   267     QWidget visibleRect property compat
       
   268     QWidget::BackgroundOrigin compat
       
   269 \endomit
       
   270 
       
   271     \section1 Type Names
       
   272 
       
   273     The table below lists the classes that have been renamed in Qt 4.
       
   274     If you compile your applications with \c QT3_SUPPORT defined, the
       
   275     old names will be available.
       
   276 
       
   277     Whenever you see an occurrence of the name on the left, you can
       
   278     safely replace it with the Qt 4 equivalent in your program. The
       
   279     \l qt3to4 tool performs the conversion automatically.
       
   280 
       
   281     \table
       
   282     \header \o Qt 3 class name \o Qt 4 class name
       
   283     \input porting/porting4-renamedclasses.qdocinc
       
   284     \endtable
       
   285 
       
   286     The table below lists the enums and typedefs that have been
       
   287     renamed in Qt 4. If you compile your applications with \c
       
   288     QT3_SUPPORT defined, the old names will be available.
       
   289 
       
   290     Whenever you see an occurrence of the name on the left, you can
       
   291     safely replace it with the Qt 4 equivalent in your program. The
       
   292     \l qt3to4 tool performs the conversion
       
   293     automatically.
       
   294 
       
   295     \table
       
   296     \header \o Qt 3 type name \o Qt 4 type name
       
   297     \input porting/porting4-renamedtypes.qdocinc
       
   298     \endtable
       
   299 
       
   300     \omit
       
   301     ###
       
   302     \row \o QButton::ToggleState \o Use QCheckBox::ToggleState instead.
       
   303     \endomit
       
   304 
       
   305     \section1 Enum Values
       
   306 
       
   307     The table below lists the enum values that have been renamed in
       
   308     Qt 4. If you compile your applications with \c QT3_SUPPORT defined,
       
   309     the old names will be available.
       
   310 
       
   311     Whenever you see an occurrence of the name on the left, you can
       
   312     safely replace it with the Qt 4 equivalent in your program. The
       
   313     \l qt3to4 tool performs the conversion automatically.
       
   314 
       
   315     \table
       
   316     \header \o Qt 3 enum value name \o Qt 4 enum value name
       
   317     \input porting/porting4-renamedenumvalues.qdocinc
       
   318     \endtable
       
   319 
       
   320     In addition, the following \l{Qt::WindowFlags}{window flags} have
       
   321     been either replaced with \l{Qt::WidgetAttribute}{widget
       
   322     attributes} or have been deprecated:
       
   323 
       
   324     \table
       
   325     \header \o Qt 3 type \o Qt 4 equivalent
       
   326     \row \o Qt::WDestructiveClose \o Use QWidget::setAttribute(Qt::WA_DeleteOnClose) instead.
       
   327     \row \o Qt::WStaticContents \o{1,2} Use QWidget::setAttribute(Qt::WA_StaticContents) instead.
       
   328     \row \o Qt::WNorthWestGravity
       
   329     \row \o Qt::WNoAutoErase \o{1,3} Use QWidget::setAttribute(Qt::WA_NoBackground) instead.
       
   330     \row \o Qt::WResizeNoErase
       
   331     \row \o Qt::WRepaintNoErase
       
   332     \row \o Qt::WPaintClever \o Unnecessary in Qt 4.
       
   333          \omit ### Check with Matthias \endomit
       
   334     \row \o Qt::WMacNoSheet \o Unnecessary in Qt 4.
       
   335          \omit ### Check with Sam \endomit
       
   336     \endtable
       
   337 
       
   338     In Qt 4.1, the widget flags used to determine window modality were
       
   339     replaced by a single enum that can be used to specify the modal
       
   340     behavior of top-level widgets:
       
   341 
       
   342     \table
       
   343     \header \o Qt 3 type \o Qt 4 equivalent
       
   344     \row \o Qt::WShowModal \o Use QWidget::setWindowModality(Qt::ApplicationModal) instead.
       
   345     \row \o Qt::WGroupLeader \o Use QWidget::setWindowModality(Qt::WindowModal)
       
   346          for each child dialog of the group leader, but do not change the modality
       
   347          of the group leader itself.
       
   348     \endtable
       
   349 
       
   350     \target properties
       
   351     \section1 Properties
       
   352 
       
   353     Some properties have been renamed in Qt 4, to make Qt's API more
       
   354     consistent and more intuitive. For example, QWidget's \c caption
       
   355     property has been renamed \c windowTitle to make it clear that it
       
   356     refers to the title shown in the window's title bar.
       
   357 
       
   358     In addition, the property system has been extended to allow
       
   359     properties to be redefined in subclasses with the \l Q_PROPERTY()
       
   360     macro, removing the need for a \c Q_OVERRIDE() macro.
       
   361 
       
   362     The table below lists the Qt properties that have been renamed in
       
   363     Qt 4. Occurrences of these in \e{Qt Designer} UI files are
       
   364     automatically converted to the new name by \c uic.
       
   365 
       
   366     \table
       
   367     \header \o Qt 3 name \o Qt 4 name
       
   368     \row \o QButton::accel \o QButton::shortcut
       
   369     \row \o QButton::on \o QButton::checked
       
   370     \row \o QButton::toggleButton \o QAbstractButton::checkable
       
   371     \row \o QDial::lineStep \o QDial::singleStep
       
   372     \row \o QDial::maxValue \o QDial::maximum
       
   373     \row \o QDial::minValue \o QDial::minimum
       
   374     \row \o QDialog::modal \o QDialog::isModal
       
   375     \row \o QLineEdit::edited \o QLineEdit::modified
       
   376     \row \o QLineEdit::hasMarkedText \o QLineEdit::hasSelectedText
       
   377     \row \o QLineEdit::markedText \o QLineEdit::selectedText
       
   378     \row \o QObject::name \o QObject::objectName
       
   379     \row \o QProgressDialog::progress \o QProgressDialog::value
       
   380     \row \o QProgressDialog::totalSteps \o QProgressDialog::maximum
       
   381     \row \o QProgressDialog::wasCancelled \o QProgressDialog::wasCanceled
       
   382     \row \o QPushButton::iconSet \o QPushButton::icon
       
   383     \row \o QScrollBar::draggingSlider \o QScrollBar::sliderDown
       
   384     \row \o QScrollBar::lineStep \o QScrollBar::singleStep
       
   385     \row \o QScrollBar::maxValue \o QScrollBar::maximum
       
   386     \row \o QScrollBar::minValue \o QScrollBar::minimum
       
   387     \row \o QSlider::lineStep \o QSlider::singleStep
       
   388     \row \o QSlider::maxValue \o QSlider::maximum
       
   389     \row \o QSlider::minValue \o QSlider::minimum
       
   390     \row \o QSpinBox::lineStep \o QSpinBox::singleStep
       
   391     \row \o QSpinBox::maxValue \o QSpinBox::maximum
       
   392     \row \o QSpinBox::minValue \o QSpinBox::minimum
       
   393     \row \o QTabBar::currentTab \o QTabBar::currentIndex
       
   394     \row \o QTabWidget::currentPage \o QTabWidget::currentWidget
       
   395     \row \o QToolButton::iconSet \o QToolButton::icon
       
   396     \row \o QToolButton::textLabel \o QToolButton::text
       
   397     \row \o QWidget::caption \o QWidget::windowTitle
       
   398     \row \o QWidget::icon \o QWidget::windowIcon
       
   399     \row \o QWidget::iconText \o QWidget::windowIconText
       
   400     \endtable
       
   401 
       
   402     A handful of properties in Qt 3 are no longer properties in Qt 4,
       
   403     but the access functions still exist as part of the Qt 4 API.
       
   404     These are not used by \e{Qt Designer}; the only case where you
       
   405     need to worry about them is in highly dynamic applications that
       
   406     use Qt's meta-object system to access properties. Here's the list
       
   407     of these properties with the read and write functions that you
       
   408     can use instead:
       
   409 
       
   410     \table
       
   411     \header \o Qt 3 property \o Qt 4 read function \o Qt 4 write function
       
   412     \row \o QSqlDatabase::connectOptions \o QSqlDatabase::connectOptions() \o QSqlDatabase::setConnectOptions()
       
   413     \row \o QSqlDatabase::databaseName \o QSqlDatabase::databaseName() \o QSqlDatabase::setDatabaseName()
       
   414     \row \o QSqlDatabase::hostName \o QSqlDatabase::hostName() \o QSqlDatabase::setHostName()
       
   415     \row \o QSqlDatabase::password \o QSqlDatabase::password() \o QSqlDatabase::setPassword()
       
   416     \row \o QSqlDatabase::port \o QSqlDatabase::port() \o QSqlDatabase::setPort()
       
   417     \row \o QSqlDatabase::userName \o QSqlDatabase::userName() \o QSqlDatabase::setUserName()
       
   418     \endtable
       
   419 
       
   420     Some properties have been removed from Qt 4, but the associated
       
   421     access functions are provided if \c QT3_SUPPORT is defined to help
       
   422     porting to Qt 4. When converting Qt 3 UI files to Qt 4, \c uic
       
   423     generates calls to the Qt 3 compatibility functions. Note that
       
   424     this only applies to the properties of the Qt3Support library,
       
   425     i.e. \c QT3_SUPPORT properties of the other libraries must be
       
   426     ported manually when converting Qt 3 UI files to Qt 4.
       
   427 
       
   428     The table below lists these properties with the read and write
       
   429     functions that you can use instead. The documentation for the
       
   430     individual functions explains how to replace them with
       
   431     non-compatibility Qt 4 functions.
       
   432 
       
   433     \table
       
   434     \header \o Qt 3 property \o Qt 4 read function (\c QT3_SUPPORT)\o Qt 4 write function (\c QT3_SUPPORT)
       
   435     \row \o QMenuBar::separator \o QMenuBar::separator() \o QMenuBar::setSeparator()
       
   436     \row \o QPushButton::menuButton \o QPushButton::isMenuButton() \o N/A
       
   437     \row \o QTabWidget::margin \o QTabWidget::margin() \o QTabWidget::setMargin()
       
   438     \row \o QTextEdit::textFormat \o QTextEdit::textFormat() \o QTextEdit::setTextFormat()
       
   439     \row \o QWidget::backgroundBrush \o QWidget::backgroundBrush() \o N/A
       
   440     \row \o QWidget::backgroundMode \o QWidget::backgroundMode() \o QWidget::setBackgroundMode()
       
   441     \row \o QWidget::backgroundOrigin \o QWidget::backgroundOrigin() \o QWidget::setBackgroundOrigin()
       
   442     \row \o QWidget::colorGroup \o QWidget::colorGroup() \o QWidget::setColorGroup()
       
   443     \row \o QWidget::customWhatsThis \o QWidget::customWhatsThis() \o QWidget::setCustomWhatsThis()
       
   444     \row \o QWidget::inputMethodEnabled \o QWidget::inputMethodEnabled() \o QWidget::setInputMethodEnabled()
       
   445     \row \o QWidget::ownCursor \o QWidget::ownCursor() \o N/A
       
   446     \row \o QWidget::ownFont \o QWidget::ownFont() \o N/A
       
   447     \row \o QWidget::ownPalette \o QWidget::ownPalette() \o N/A
       
   448     \row \o QWidget::paletteBackgroundColor \o QWidget::paletteBackgroundColor() \o QWidget::setPaletteBackgroundColor()
       
   449     \row \o QWidget::paletteBackgroundPixmap \o QWidget::paletteBackgroundPixmap() \o QWidget::setPaletteBackgroundPixmap()
       
   450     \row \o QWidget::paletteForegroundColor \o QWidget::paletteForegroundColor() \o QWidget::setPaletteForegroundColor()
       
   451     \row \o QWidget::underMouse \o QWidget::underMouse() \o N/A
       
   452     \endtable
       
   453 
       
   454     The following Qt 3 properties and their access functions are no
       
   455     longer available in Qt 4. In most cases, Qt 4 provides similar
       
   456     functionality.
       
   457 
       
   458     \table
       
   459     \header \o Qt 3 property \o Qt 4 equivalent
       
   460     \row \o QButton::autoRepeat \o N/A
       
   461     \row \o QButton::autoResize \o Call QWidget:setFixedSize(QWidget::sizeHint()) whenever you change the contents.
       
   462     \row \o QButton::exclusiveToggle \o See \l QAbstractButton::autoExclusive.
       
   463     \row \o QButton::pixmap \o Use QAbstractButton::icon instead.
       
   464     \row \o QButton::toggleState \o Use QCheckBox::setState() and QCheckBox::state() instead.
       
   465     \row \o QButton::toggleType \o Use QCheckBox::setTristate() instead.
       
   466     \row \o QComboBox::autoResize \o Call QWidget:setFixedSize(QWidget::sizeHint()) whenever you change the contents.
       
   467     \row \o QFrame::contentsRect \o Use Q3Frame::contentsRect() instead.
       
   468     \row \o QFrame::margin \o Use QWidget::setContentsMargins() instead.
       
   469     \row \o QTabBar::keyboardFocusTab \o N/A
       
   470     \row \o QToolButton::offIconSet \o Use the \l{QIcon::Off}{off component} of QAbstractButton::icon instead.
       
   471     \row \o QToolButton::onIconSet \o Use the \l{QIcon::On}{on component} of QAbstractButton::icon instead.
       
   472     \row \o QWidget::microFocusHint \o N/A
       
   473     \row \o QMimeSource::serialNumber () \o N/A 
       
   474     \endtable
       
   475 
       
   476 \omit
       
   477     \section1 Inheritance Chain
       
   478 
       
   479     ### QMenuBar, etc.
       
   480 
       
   481     \section1 Null vs. Empty
       
   482 
       
   483     ###
       
   484 \endomit
       
   485 
       
   486     \section1 Explicit Sharing
       
   487 
       
   488     Qt 4 is the first version of Qt that contains no \link
       
   489     http://qt.nokia.com/doc/3.3/shclass.html explicitly shared
       
   490     \endlink classes. All classes that were explicitly shared in Qt 3
       
   491     are \e implicitly shared in Qt 4:
       
   492 
       
   493     \list
       
   494     \o QImage
       
   495     \o QBitArray
       
   496     \o QByteArray
       
   497     \o Q3PointArray
       
   498     \endlist
       
   499 
       
   500     This means that if you took a copy of an instance of the class
       
   501     (using operator=() or the class's copy constructor), any
       
   502     modification to the copy would affect the original and vice
       
   503     versa. Needless to say, this behavior is rarely desirable.
       
   504 
       
   505     Fortunately, nearly all Qt 3 applications don't rely on explicit
       
   506     sharing. When porting, you typically only need to remove calls to
       
   507     detach() and/or copy(), which aren't necessary anymore.
       
   508 
       
   509     If you deliberately rely on explicit sharing in your application,
       
   510     you can use pointers or references to achieve the same result in
       
   511     Qt 4.
       
   512 
       
   513     \oldcode
       
   514         void asciify(QByteArray array)
       
   515         {
       
   516             for (int i = 0; i < (int)array.size(); ++i) {
       
   517                 if ((uchar)array[i] >= 128)
       
   518                     array[i] = '?';
       
   519             }
       
   520         }
       
   521     \newcode
       
   522         void asciify(QByteArray &array)
       
   523         {
       
   524             for (int i = 0; i < array.size(); ++i) {
       
   525                 if ((uchar)array[i] >= 128)
       
   526                     array[i] = '?';
       
   527             }
       
   528         }
       
   529     \endcode
       
   530 
       
   531     (Notice the \c & in the parameter declaration.)
       
   532 
       
   533 \omit
       
   534     \section1 Qt Designer UI Files
       
   535 
       
   536     ###
       
   537 \endomit
       
   538 
       
   539     \section1 Painting and Redrawing Widgets
       
   540 
       
   541     When implementing custom widgets in Qt 3, it was possible to use
       
   542     QPainter to draw on a widget outside paint events. This made it
       
   543     possible to integrate Qt applications with third party libraries
       
   544     and tools that impose their own rendering models. For example,
       
   545     a widget might be repainted in a slot using data obtained from
       
   546     an external source.
       
   547 
       
   548     In Qt 4, it is only possible to paint on a widget from within its
       
   549     \l{QWidget::}{paintEvent()} handler function. This restriction simplifies
       
   550     Qt's interaction with native window systems, improves the performance
       
   551     of applications by reducing the number of redraw operations, and
       
   552     also enables features to be implemented to improve the appearance of
       
   553     widgets, such as a backing store.
       
   554 
       
   555     Generally, we recommend redesigning applications to perform all
       
   556     painting operations in \l{QWidget::}{paintEvent()} functions, deferring
       
   557     actual painting until the next time this function is called.
       
   558     Applications can post paint events to trigger repaints, and it may be
       
   559     possible to examine your widget's internal state to determine which
       
   560     part of the widget needs to be repainted.
       
   561 
       
   562     If asynchronous repaints are used extensively by your application,
       
   563     and it is not practical to redesign the rendering model to perform
       
   564     all painting operations from within a widget's \l{QWidget::}{paintEvent()}
       
   565     function, it may be necessary to consider using an intermediate painting
       
   566     step. In this approach, one or more images can be updated asynchronously
       
   567     and painted on the widget in the paint event. To avoid excessive
       
   568     buffering, it may be worthwhile disabling the backing store by setting
       
   569     the widget's Qt::WA_PaintOnScreen widget attribute.
       
   570 
       
   571     On certain platforms, the Qt::WA_PaintOutsidePaintEvent widget attribute
       
   572     can be set to allow a widget to be painted from outside paint events.
       
   573 
       
   574     \note Setting widget attributes to disable key features of Qt's widget
       
   575     rendering model may also cause other features to be disabled.
       
   576 
       
   577     \section1 Compatibility Signals and Slots
       
   578 
       
   579     When \c QT3_SUPPORT is defined, the default connection type for signals
       
   580     and slots is the Qt::AutoCompatConnection type. This allows so-called
       
   581     \e compatibility signals and slots (defined in Qt 3 support mode to provide
       
   582     Qt 3 compatibility features) to be connected to other signals and
       
   583     slots.
       
   584 
       
   585     However, if Qt is compiled with debugging output enabled, and the
       
   586     developer uses other connection types to connect to compatibility
       
   587     signals and slots (perhaps by building their application without Qt 3
       
   588     support enabled), then Qt will output warnings to the console to
       
   589     indicate that compatibility connections are being made. This is intended
       
   590     to be used as an aid in the process of porting a Qt 3 application to Qt 4.
       
   591 
       
   592     \section1 QAccel
       
   593 
       
   594     The \c QAccel class has been renamed Q3Accel and moved to the
       
   595     Qt3Support module. In new applications, you have three options:
       
   596 
       
   597     \list 1
       
   598     \o You can use QAction and set a key sequence using QAction::setShortcut().
       
   599     \o You can use QShortcut, a class that provides similar
       
   600        functionality to Q3Accel.
       
   601     \o You can use QWidget::grabShortcut() and process "shortcut"
       
   602        events by reimplementing QWidget::event().
       
   603     \endlist
       
   604 
       
   605     The Q3Accel class also supports multiple accelerators using the
       
   606     same object, by calling Q3Accel::insertItem() multiple times. In
       
   607     Qt 4, the solution is to create multiple QShortcut objects.
       
   608 
       
   609     \section1 QAccessibleInterface
       
   610 
       
   611     The QAccessibleInterface class has undergone some API changes in
       
   612     Qt 4, to make it more consistent with the rest of the Qt API.
       
   613 
       
   614     If you have classes that inherit QAccessibleInterface or one of
       
   615     its subclasses (QAccessibleObject, QAccessibleWidget, etc.), you
       
   616     must port them the new QAccessibleInterface API.
       
   617 
       
   618     See \l{Porting to Qt 4 - Virtual Functions}{Virtual Functions}
       
   619     for a list of QAccessibleInterface virtual member functions in
       
   620     Qt 3 that are no longer virtual in Qt 4.
       
   621 
       
   622     \section1 QAccessibleTitleBar
       
   623 
       
   624     The \c QAccessibleTitleBar has been renamed Q3AccessibleTitleBar
       
   625     and moved to the Qt3Support library.
       
   626 
       
   627     \target qaction.section
       
   628     \section1 QAction
       
   629 
       
   630     The QAction class has been redesigned in Qt 4 to integrate better
       
   631     with the rest of the menu system. It unifies the old \c QMenuItem
       
   632     class and the old \c QAction class into one class, avoiding
       
   633     unnecessary data duplication and the need to learn two different
       
   634     APIs.
       
   635 
       
   636     The old \c QAction and \c QActionGroup classes have been renamed
       
   637     Q3Action and Q3ActionGroup and moved to Qt3Support. In addition,
       
   638     the new QAction class has compatibility functions to ease
       
   639     transition to Qt 4. Note that when using Q3ToolBar and
       
   640     Q3PopupMenu, their actions must be \l {Q3Action}s.
       
   641 
       
   642     See \l{Porting to Qt 4 - Virtual Functions}{Virtual Functions}
       
   643     for a list of QAction virtual member functions in Qt 3 that are
       
   644     no longer virtual in Qt 4.
       
   645 
       
   646     \section1 QActionGroup
       
   647 
       
   648     The QAction class has been completely redesigned in Qt 4 to
       
   649     integrate better with the rest of the menu system. See the
       
   650     \l{#qaction.section}{section on QAction} for details.
       
   651 
       
   652     \section1 QApplication
       
   653 
       
   654     The QApplication class has been split into two classes:
       
   655     QCoreApplication and QApplication. The new QApplication class
       
   656     inherits QCoreApplication and adds GUI-related functionality. In
       
   657     practice, this has no consequences for existing Qt applications.
       
   658 
       
   659     In addition, the following API changes were made:
       
   660 
       
   661     \list 1
       
   662     \o  QApplication::allWidgets() and QApplication::topLevelWidgets()
       
   663         used to return a pointer to a QWidgetList. Now they return a
       
   664         QWidgetList.
       
   665 
       
   666         Also, QWidgetList has changed from being a typedef for
       
   667         QPtrList<QWidget> to being a typedef for QList<QWidget *>.
       
   668         See the \l{#qwidgetlist.section}{section on QWidgetList} below
       
   669         for details.
       
   670 
       
   671         \oldcode
       
   672             QWidgetList *list = QApplication::topLevelWidgets();
       
   673             QWidgetListIt it(*list);
       
   674             QWidget *widget;
       
   675             while ((widget = it.current())) {
       
   676                 if (widget->inherits("MainWindow"))
       
   677                     ((MainWindow *)widget)->updateRecentFileItems();
       
   678                 ++it;
       
   679             }
       
   680             delete list;
       
   681         \newcode
       
   682             QWidgetList list = QApplication::topLevelWidgets();
       
   683             for (int i = 0; i < list.size(); ++i) {
       
   684                 if (MainWindow *mainWin = qobject_cast<MainWindow *>(list.at(i)))
       
   685                     mainWin->updateRecentFileItems();
       
   686             }
       
   687         \endcode
       
   688     \o QApplication::setMainWidget() is no longer used. When all an application's
       
   689        windows are closed, the application will exit normally.
       
   690     \endlist
       
   691 
       
   692     \section1 QAquaStyle
       
   693 
       
   694     The \c QAquaStyle class first appeared in Qt 3.0, when the Qt for
       
   695     Mac OS X port was first released. It emulated Apple's "Aqua" theme.
       
   696     In Qt 3.1, QAquaStyle was obsoleted by QMacStyle, which uses Appearance
       
   697     Manager to perform its drawing.
       
   698 
       
   699     The \c QAquaStyle class is no longer provided in Qt 4. Use
       
   700     QMacStyle instead.
       
   701 
       
   702     \target qasciidict.section
       
   703     \section1 QAsciiCache<T>
       
   704 
       
   705     \c QAsciiCache<T> has been renamed Q3AsciiCache<T> and moved to
       
   706     the Qt3Support library. It has been replaced by
       
   707     QCache<QByteArray, T>.
       
   708 
       
   709     For details, read the \l{#qcache.section}{section on QCache<T>},
       
   710     mentally substituting QByteArray for QString.
       
   711 
       
   712     \section1 QAsciiDict<T>
       
   713 
       
   714     QAsciiDict<T> and QAsciiDictIterator<T> have been renamed
       
   715     Q3AsciiDict<T> and Q3AsciiDictIterator<T> and moved to the
       
   716     Qt3Support library. They have been replaced by the
       
   717     more modern QHash<Key, T> and QMultiHash<Key, T> classes and
       
   718     their associated iterator classes.
       
   719 
       
   720     When porting old code that uses Q3AsciiDict<T> to Qt 4, there are
       
   721     four classes that you can use:
       
   722 
       
   723     \list
       
   724     \o QMultiHash<QByteArray, T *>
       
   725     \o QMultiHash<QByteArray, T>
       
   726     \o QHash<QByteArray, T *>
       
   727     \o QHash<QByteArray, T>
       
   728     \endlist
       
   729 
       
   730     For details, read the \l{#qdict.section}{section on QDict<T>},
       
   731     mentally substituting QByteArray for QString.
       
   732 
       
   733     \section1 QAsyncIO
       
   734 
       
   735     The \c QAsyncIO class was used internally in Qt 2.x in
       
   736     conjunction with QImageConsumer. It was obsoleted in Qt 3.0.
       
   737 
       
   738     \input porting/porting4-obsoletedmechanism.qdocinc
       
   739 
       
   740     \section1 QBackInsertIterator
       
   741 
       
   742     The undocumented \c QBackInsertIterator class has been removed
       
   743     from the Qt library. If you need it in your application, feel
       
   744     free to copy the source code from the Qt 3 \c <qtl.h> header
       
   745     file.
       
   746 
       
   747     \section1 QBitArray
       
   748 
       
   749     In Qt 3, QBitArray inherited from QByteArray. In Qt 4, QBitArray
       
   750     is a totally independent class. This makes very little difference
       
   751     to the user, except that the new QBitArray doesn't provide any of
       
   752     QByteArray's byte-based API anymore. These calls will result in a
       
   753     compile-time error, except calls to QBitArray::truncate(), whose
       
   754     parameter was a number of \e bytes in Qt 3 and a number of bits
       
   755     in Qt 4.
       
   756 
       
   757     QBitArray was an explicitly shared class in Qt 3. See \l{Explicit
       
   758     Sharing} for more information.
       
   759 
       
   760     The \c QBitVal class has been renamed QBitRef.
       
   761 
       
   762     \section1 QButton
       
   763 
       
   764     The \c QButton class has been replaced by QAbstractButton in Qt
       
   765     4. Classes like QPushButton and QRadioButton inherit from
       
   766     QAbstractButton. As a help when porting older Qt applications,
       
   767     the Qt3Support library contains a Q3Button class
       
   768     implemented in terms of the new QAbstractButton.
       
   769 
       
   770     If you used the \c QButton class as a base class for your own
       
   771     button type and want to port your code to the newer
       
   772     QAbstractButton, you need to be aware that QAbstractButton has no
       
   773     equivalent for the Q3Button::drawButton(QPainter *) virtual
       
   774     function. The solution is to reimplement QWidget::paintEvent() in
       
   775     your QAbstractButton subclass as follows:
       
   776 
       
   777     \snippet doc/src/snippets/code/doc_src_porting4.qdoc 0
       
   778 
       
   779     \table
       
   780     \header \o Q3Button function \o QAbstractButton equivalent
       
   781     \row \o Q3Button::autoResize() \o Call QWidget:setFixedSize(QWidget::sizeHint()) whenever you change the contents.
       
   782     \row \o Q3Button::isExclusiveToggle() \o Use QAbstractButton::group() or QAbstractButton::autoExclusive() instead.
       
   783     \row \o Q3Button::pixmap() const \o QAbstractButton::icon()
       
   784     \row \o Q3Button::setAutoResize() \o N/A
       
   785     \row \o Q3Button::setPixmap(const QPixmap &) \o QAbstractButton::setIcon(const QIcon &)
       
   786     \row \o Q3Button::setState(ToggleState) \o See remark below
       
   787     \row \o Q3Button::setToggleType(ToggleType) \o See remark below
       
   788     \row \o Q3Button::state() \o See remark below
       
   789     \row \o Q3Button::stateChanged(int) \o See remark below
       
   790     \row \o Q3Button::toggleType() \o See remark below
       
   791     \endtable
       
   792 
       
   793     Remarks:
       
   794 
       
   795     \list 1
       
   796     \o In Qt 3, \c QButton had a "toggle type", which could be
       
   797        QButton::SingleShot, QButton::Toggle, or QButton::Tristate.
       
   798        The new QAbstractButton class doesn't support "tristate"
       
   799        directly; this feature is implemented in QCheckBox instead.
       
   800        The two other "toggle types" (\c QButton::SingleShot and \c
       
   801        QButton::Toggle) are replaced by a QAbstractButton::checkable
       
   802        property.
       
   803     \o In Qt 3, QButton had a "toggle state", which could be \c
       
   804        QButton::Off, \c QButton::NoChange, or \c QButton::On. In Qt
       
   805        4, this mechanism has been moved to QCheckBox.
       
   806     \endlist
       
   807 
       
   808     See \l{Porting to Qt 4 - Virtual Functions}{Virtual Functions} for
       
   809     a list of \c QButton virtual member functions in Qt 3 that aren't
       
   810     virtual in Qt 4.
       
   811 
       
   812     See \l{#properties}{Properties} for a list of \c QButton properties
       
   813     in Qt 3 that have changed in Qt 4.
       
   814 
       
   815     \section1 QButtonGroup
       
   816 
       
   817     The \c QButtonGroup class has been completely redesigned in Qt 4.
       
   818     For compatibility, the old \c QButtonGroup class has been renamed
       
   819     Q3ButtonGroup and has been moved to Qt3Support.
       
   820     Likewise, the \c QHButtonGroup and \c QVButtonGroup convenience
       
   821     subclasses have been renamed \c Q3HButtonGroup and \c Q3VButtonGroup and
       
   822     moved to the Qt3Support library.
       
   823 
       
   824     The old \c QButtonGroup, as well as Q3ButtonGroup, can be used in two ways:
       
   825 
       
   826     \list 1
       
   827     \o  The button group is the parent widget of a number of buttons,
       
   828         i.e. the button group is the parent argument in the button
       
   829         constructor. The buttons are assigned identifiers 0, 1, 2, etc.,
       
   830         in the order they are created. A Q3ButtonGroup can display a frame
       
   831         and a title because it inherits Q3GroupBox.
       
   832     \o  The button group is an invisible widget and the contained
       
   833         buttons have some other parent widget. In this usage, each
       
   834         button must be manually inserted, using
       
   835         Q3ButtonGroup::insert(), into the button group and given an
       
   836         ID number.
       
   837     \endlist
       
   838 
       
   839     Unlike Q3ButtonGroup, the new QButtonGroup doesn't inherit
       
   840     QWidget. It is very similar to a "hidden Q3ButtonGroup".
       
   841 
       
   842     If you use a Q3ButtonGroup, Q3HButtonGroup, or Q3VButtonGroup as
       
   843     a widget and want to port to Qt 4, you can replace it with
       
   844     QGroupBox. In Qt 4, radio buttons with the same parent are
       
   845     automatically part of an exclusive group, so you normally don't
       
   846     need to do anything else. See also the
       
   847     \l{#qgroupbox.section}{section on QGroupBox} below.
       
   848 
       
   849     See \l{Porting to Qt 4 - Virtual Functions}{Virtual Functions} for
       
   850     a list of QButtonGroup virtual member functions in Qt 3 that are no
       
   851     longer virtual in Qt 4.
       
   852 
       
   853     \target qbytearray.section
       
   854     \section1 QByteArray
       
   855 
       
   856     In Qt 3, QByteArray was simply a typedef for QMemArray<char>. In
       
   857     Qt 4, QByteArray is a class in its own right, with a higher-level
       
   858     API in the style of QString.
       
   859 
       
   860     Here are the main issues to be aware of when porting to Qt 4:
       
   861 
       
   862     \list 1
       
   863     \o  The QMemArray(int size) constructor has been replaced with
       
   864         QByteArray(int size, char ch). The second argument specifies
       
   865         which character should be used for initializing the array;
       
   866         pass '\\0' if you have no specific needs.
       
   867 
       
   868         \oldcode
       
   869         QByteArray ba(64);
       
   870         \newcode
       
   871         QByteArray ba(64, '\0');
       
   872         \endcode
       
   873 
       
   874     \o  QMemArray::at() returned a non-const reference, whereas the
       
   875         new QByteArray::at() returns a const value. Code like
       
   876 
       
   877         \snippet doc/src/snippets/code/doc_src_porting4.qdoc 1
       
   878 
       
   879         will no longer compile. Instead, use QByteArray::operator[]:
       
   880 
       
   881         \snippet doc/src/snippets/code/doc_src_porting4.qdoc 2
       
   882 
       
   883     \o  The QMemArray::contains(char) function has been renamed
       
   884         QByteArray::count(char). In addition, there now exists a
       
   885         QByteArray::contains(char) function that returns a boolean
       
   886         value. Replace old calls to contains() with either count() or
       
   887         contains(), depending on whether you care about the specific
       
   888         number of occurrences of a character in the byte array or
       
   889         only care about whether the array contains that character or
       
   890         not.
       
   891 
       
   892     \o  The new QByteArray has no assign() function. Calls to
       
   893         QMemArray::assign(const QMemArray &) can be replaced by calls
       
   894         to QByteArray::operator=(). Calls to QMemArray::assign(const
       
   895         T *, uint) have no equivalent in Qt 4; if you use it, the
       
   896         solution is either to use QByteArray::fromRawData() and to
       
   897         call free() yourself to avoid a memory leak, or to use the
       
   898         QByteArray(const char *, int) constructor, which will take a
       
   899         deep copy of the data.
       
   900 
       
   901     \o  QMemArray::bsearch() and QMemArray::sort() have no equivalent
       
   902         in the new QByteArray class. Use \l qBinaryFind() and \l qSort()
       
   903         if you need that functionality.
       
   904     \endlist
       
   905 
       
   906     QByteArray was an explicitly shared class in Qt 3. See
       
   907     \l{Explicit Sharing} for more information.
       
   908 
       
   909     \target qcache.section
       
   910     \section1 QCache<T>
       
   911 
       
   912     QCache<T> has been renamed Q3Cache<T> and moved to Qt3Support.
       
   913     The new QCache class has a different API, and takes different
       
   914     template parameters: QCache<Key, T>.
       
   915 
       
   916     When porting to Qt 4, QCache<QString, T> is the obvious
       
   917     substitute for Q3Cache<T>. The following table summarizes the API
       
   918     differences.
       
   919 
       
   920     \table
       
   921     \header \o Q3Cache<T> function \o QCache<QString, T> equivalent
       
   922     \row \o Q3Cache::Q3Cache(int maxCost, int size, bool caseSensitive) \o See remark below
       
   923     \row \o Q3Cache::autoDelete() \o N/A
       
   924     \row \o Q3Cache::count() \o QCache::count() or QCache::size() (equivalent)
       
   925     \row \o Q3Cache::setAutoDelete() \o See remark below
       
   926     \row \o Q3Cache::size() \o N/A
       
   927     \row \o Q3Cache::statistics() \o N/A
       
   928     \row \o Q3Cache::operator=() \o See remark below
       
   929     \endtable
       
   930 
       
   931     Remarks:
       
   932 
       
   933     \list 1
       
   934     \o  Q3Cache requires the user to allocate a specific number of
       
   935         buckets by passing a prime number (17 by default) to the
       
   936         constructor. In contrast, the new QCache's hash table
       
   937         automatically grows and shrinks as needed, and the
       
   938         constructor doesn't take a prime number.
       
   939 
       
   940     \o  Q3Cache supportes case-insensitive lookups by passing false as
       
   941         second argument to the constructor. This feature has no
       
   942         equivalent in QMultiHash. Instead, call QString::toLower()
       
   943         before you insert or lookup a key in the hash.
       
   944 
       
   945     \o  The Q3Cache::insert() function returns a \c bool value that
       
   946         indicates whether or not the item actually was inserted in
       
   947         the cache. If the item wasn't inserted, it was the caller's
       
   948         responsibility to delete the item. The new QCache::insert()
       
   949         function returns \c void and either adds it to the cache or
       
   950         deletes it right away. Old code like
       
   951 
       
   952         \snippet doc/src/snippets/code/doc_src_porting4.qdoc 3
       
   953 
       
   954     becomes
       
   955 
       
   956         \snippet doc/src/snippets/code/doc_src_porting4.qdoc 4
       
   957 
       
   958     \o  The new QCache class \e always takes ownership of the items
       
   959         it stores (i.e. auto-delete is always on). If you use Q3Cache
       
   960         with auto-delete turned off (the rarely useful default), you
       
   961         cannot use QCache as a direct substitute. One unelegant trick
       
   962         that works well in practice is to use QCache<QString, T *>
       
   963         instead of QCache<QString, T>. In that case, QCache owns the
       
   964         pointers, not the objects that the pointers refer to. For
       
   965         example,
       
   966 
       
   967         \snippet doc/src/snippets/code/doc_src_porting4.qdoc 5
       
   968 
       
   969         becomes
       
   970 
       
   971         \snippet doc/src/snippets/code/doc_src_porting4.qdoc 6
       
   972 
       
   973         An alternative is to stick to using Q3Cache.
       
   974     \endlist
       
   975 
       
   976     QCacheIterator<T> has been renamed Q3CacheIterator<T> and moved
       
   977     to the Qt3Support library. The new QCache class
       
   978     doesn't offer any iterator types.
       
   979 
       
   980     \section1 QCanvas
       
   981 
       
   982     The canvas module classes have been
       
   983     renamed and moved to the Qt3Support library.
       
   984 
       
   985     \table
       
   986     \header \o Qt 3 class name \o Compatibility class in Qt 4
       
   987     \row \o \c QCanvas \o Q3Canvas
       
   988     \row \o \c QCanvasEllipse \o Q3CanvasEllipse
       
   989     \row \o \c QCanvasItem \o Q3CanvasItem
       
   990     \row \o \c QCanvasItemList \o Q3CanvasItemList
       
   991     \row \o \c QCanvasLine \o Q3CanvasLine
       
   992     \row \o \c QCanvasPixmap \o Q3CanvasPixmap
       
   993     \row \o \c QCanvasPixmapArray \o Q3CanvasPixmapArray
       
   994     \row \o \c QCanvasPolygon \o Q3CanvasPolygon
       
   995     \row \o \c QCanvasPolygonalItem \o Q3CanvasPolygonalItem
       
   996     \row \o \c QCanvasRectangle \o Q3CanvasRectangle
       
   997     \row \o \c QCanvasSpline \o Q3CanvasSpline
       
   998     \row \o \c QCanvasSprite \o Q3CanvasSprite
       
   999     \row \o \c QCanvasText \o Q3CanvasText
       
  1000     \row \o \c QCanvasView \o Q3CanvasView
       
  1001     \endtable
       
  1002 
       
  1003     \l{The Graphics View Framework} replaces QCanvas. For more on porting to
       
  1004     Graphics View, see \l{Porting to Graphics View}.
       
  1005 
       
  1006     \section1 QColor
       
  1007 
       
  1008     In Qt 4, QColor is a value type like QPoint or QRect. Graphics
       
  1009     system-specific code has been implemented in QColormap.
       
  1010 
       
  1011     The \c QColor::maxColors() function has been replaced
       
  1012     by QColormap::size().
       
  1013 
       
  1014     The \c QColor::numBitPlanes() function has been replaced
       
  1015     by QColormap::depth().
       
  1016 
       
  1017     The \c QColor::setNamedColor() function no longer supports
       
  1018     the named color in the same way as Qt 3. Qt 4's
       
  1019     \l{QColor::}{setNamedColor()} uses the new W3C convention
       
  1020     as stated 
       
  1021     \l{http://www.w3.org/TR/SVG/types.html#ColorKeywords}{here}.
       
  1022 
       
  1023     \table
       
  1024     \header \o{4,1} Predefined Qt Colors
       
  1025     \row \o Qt::color0 \o Qt::color1 \o Qt::black \o Qt::white
       
  1026     \row \o Qt::darkGray \o Qt::gray \o Qt::lightGray \o Qt::red
       
  1027     \row \o Qt::green \o Qt::blue \o Qt::cyan \o Qt::magenta
       
  1028     \row \o Qt::yellow \o Qt::darkRed \o Qt::darkGreen \o Qt::darkBlue
       
  1029     \row \o Qt::darkCyan \o Qt::darkMagenta \o Qt::darkYellow \o Qt::transparent
       
  1030     \endtable
       
  1031 
       
  1032     The predefined colors listed in the table above were static
       
  1033     QColor objects in Qt 3. In Qt 4, they are enum values of type
       
  1034     Qt::GlobalColor. Thanks to the implicit QColor(Qt::GlobalColor)
       
  1035     constructor, the enum values are automatically converted to
       
  1036     \l{QColor}s in most contexts. Occasionally, you might need a
       
  1037     cast.
       
  1038 
       
  1039     \oldcode
       
  1040         QColor lightCyan = Qt::cyan.light(180);
       
  1041     \newcode
       
  1042         QColor lightCyan = QColor(Qt::cyan).light(180);
       
  1043     \endcode
       
  1044 
       
  1045     \section1 QColorGroup
       
  1046 
       
  1047     In Qt 3, a QPalette consisted of three QColorGroup objects. In Qt
       
  1048     4, the (rarely used) QColorGroup abstraction has been eliminated.
       
  1049     For source compatibility, a QColorGroup class is available when
       
  1050     \c QT3_SUPPORT is defined.
       
  1051 
       
  1052     The new QPalette still works in terms of color groups, specified
       
  1053     through enum values (QPalette::Active, QPalette::Disabled, and
       
  1054     QPalette::Inactive). It also has the concept of a \e current
       
  1055     color group, which you can set using
       
  1056     QPalette::setCurrentColorGroup().
       
  1057 
       
  1058     The QPalette object returned by QWidget::palette() returns a
       
  1059     QPalette initialized with the correct current color group for the
       
  1060     widget. This means that if you had code like
       
  1061 
       
  1062     \badcode
       
  1063         painter.setBrush(colorGroup().brush(QColorGroup::Text));
       
  1064     \endcode
       
  1065 
       
  1066     you can simply replace colorGroup() with palette():
       
  1067 
       
  1068     \snippet doc/src/snippets/code/doc_src_porting4.qdoc 7
       
  1069 
       
  1070     \section1 QColorDrag
       
  1071 
       
  1072     The \c QColorDrag class has been renamed Q3ColorDrag and moved to
       
  1073     the Qt3Support library. In Qt 4, use QMimeData
       
  1074     instead and call QMimeData::setColor() to set the color.
       
  1075 
       
  1076     \section1 QComboBox
       
  1077 
       
  1078     In Qt 3, the list box used to display the contents of a \c QComboBox
       
  1079     widget could be accessed by using the \c listBox() function. In Qt 4,
       
  1080     the standard list box is provided by a QListView widget, and can be
       
  1081     accessed with the \l{QComboBox::view()}{view()} function.
       
  1082 
       
  1083     \omit ### \endomit
       
  1084 
       
  1085     See \l{Porting to Qt 4 - Virtual Functions}{Virtual Functions} for
       
  1086     a list of QComboBox virtual member functions in Qt 3 that are no longer
       
  1087     virtual in Qt 4.
       
  1088 
       
  1089     \section1 QCString
       
  1090 
       
  1091     In Qt 3, QCString inherited from QByteArray. The main drawback
       
  1092     of this approach is that the user had the responsibility of
       
  1093     ensuring that the string is '\\0'-terminated. Another important
       
  1094     issue was that conversions between \c QCString and QByteArray often
       
  1095     gave confusing results. (See the
       
  1096     \l{http://qt.nokia.com/doc/qq/qq05-achtung.html#qcstringisastringofchars}{Achtung!
       
  1097     Binary and Character Data} article in \e{Qt Quarterly} for an
       
  1098     overview of the pitfalls.)
       
  1099 
       
  1100     Qt 4 solves that problem by merging the QByteArray and \c QCString
       
  1101     classes into one class called QByteArray. Most functions that
       
  1102     were in \c QCString previously have been moved to QByteArray. The
       
  1103     '\\0' issue is handled by having QByteArray allocate one extra
       
  1104     byte that it always sets to '\\0'. For example:
       
  1105 
       
  1106     \snippet doc/src/snippets/code/doc_src_porting4.qdoc 8
       
  1107 
       
  1108     The Qt3Support library contains a class called
       
  1109     Q3CString that inherits from the new QByteArray class and that
       
  1110     extends it to provide an API that is as close to the old \c QCString
       
  1111     class as possible. Note that the following functions aren't
       
  1112     provided by Q3CString:
       
  1113 
       
  1114     \list
       
  1115     \o QCString::find(const QRegExp &, int)
       
  1116     \o QCString::findRev(const QRegExp &, int)
       
  1117     \o QCString::contains(const QRegExp &)
       
  1118     \o QCString::replace(const QRegExp &, const char *)
       
  1119     \endlist
       
  1120 
       
  1121     The following functions have lost their last parameter, which
       
  1122     specified whether the search was case sensitive or not:
       
  1123 
       
  1124     \list
       
  1125     \o QByteArray::find(char, int)
       
  1126     \o QByteArray::find(const char *, int)
       
  1127     \o QByteArray::findRev(char, int)
       
  1128     \o QByteArray::findRev(const char *, int)
       
  1129     \o QByteArray::contains(char)
       
  1130     \o QByteArray::contains(const char *)
       
  1131     \endlist
       
  1132 
       
  1133     In both cases, the solution is to convert the \c QCString to a
       
  1134     QString and use the corresponding QString functions instead.
       
  1135 
       
  1136     Also be aware that \c QCString::size() (inherited from
       
  1137     QByteArray) used to return the size of the character data \e
       
  1138     including the '\\0'-terminator, whereas the new
       
  1139     QByteArray::size() is just a synonym for QByteArray::length().
       
  1140     This brings QByteArray in line with QString.
       
  1141 
       
  1142     When porting to Qt 4, occurrences of \c QCString should be
       
  1143     replaced with QByteArray or QString. The following table
       
  1144     summarizes the API differences between the Q3CString
       
  1145     class and the Qt 4 QByteArray and QString classes:
       
  1146 
       
  1147     \table
       
  1148     \header \o Q3CString function \o Qt 4 equivalent
       
  1149     \row \o Q3CString::Q3CString(const char *, uint) \o See remark below
       
  1150     \row \o Q3CString::Q3CString(int) \o QByteArray::QByteArray(int, char)
       
  1151     \row \o Q3CString::leftJustify() \o QString::leftJustified()
       
  1152     \row \o Q3CString::length() \o QByteArray::length() or QByteArray::size() (equivalent)
       
  1153     \row \o Q3CString::lower() \o QByteArray::toLower()
       
  1154     \row \o Q3CString::rightJustify() \o QString::rightJustified()
       
  1155     \row \o Q3CString::setExpand() \o See remark below
       
  1156     \row \o Q3CString::simplifyWhiteSpace() \o QByteArray::simplified()
       
  1157     \row \o Q3CString::sprintf() \o QString::sprintf()
       
  1158     \row \o Q3CString::stripWhiteSpace() \o QByteArray::trimmed()
       
  1159     \row \o Q3CString::toDouble() \o QString::toDouble()
       
  1160     \row \o Q3CString::toFloat() \o QString::toFloat()
       
  1161     \row \o Q3CString::toInt() \o QString::toInt()
       
  1162     \row \o Q3CString::toLong() \o QString::toLong()
       
  1163     \row \o Q3CString::toShort() \o QString::toShort()
       
  1164     \row \o Q3CString::toUInt() \o QString::toUInt()
       
  1165     \row \o Q3CString::toULong() \o QString::toULong()
       
  1166     \row \o Q3CString::toUShort() \o QString::toUShort()
       
  1167     \row \o Q3CString::upper() \o QByteArray::toUpper()
       
  1168     \endtable
       
  1169 
       
  1170     Remarks:
       
  1171 
       
  1172     \list 1
       
  1173     \o  Q3CString(const char *str, uint max) constructs a string of
       
  1174         length strlen(str) or \e max - 1, whichever is shorter.
       
  1175         QByteArray(const char *data, int size) constructs a byte
       
  1176         array containing exactly \e size bytes.
       
  1177 
       
  1178         \oldcode
       
  1179             QCString str1("Hello", 4);           // "Hel"
       
  1180             QCString str2("Hello world!", n);
       
  1181         \newcode
       
  1182             QByteArray str1("Hello", 3);
       
  1183             QByteArray str2("Hello world!");
       
  1184             str2.truncate(n - 1);
       
  1185         \endcode
       
  1186 
       
  1187     \o  Q3CString::setExpand(uint index, char ch) has no equivalent in
       
  1188         Qt 4.
       
  1189 
       
  1190         \oldcode
       
  1191             QCString str("Hello world");
       
  1192             str.setExpand(16, '\n');            // "Hello world     \n"
       
  1193         \newcode
       
  1194             QByteArray str("Hello world");
       
  1195             while (str.size() < 16)
       
  1196                 str += ' ';
       
  1197             str += '\n';
       
  1198         \endcode
       
  1199     \endlist
       
  1200 
       
  1201     Since the old \c QCString class inherited from QByteArray,
       
  1202     everything that is said in the \l{#qbytearray.section}{QByteArray
       
  1203     section} applies for \c QCString as well.
       
  1204 
       
  1205     \section1 QCustomEvent
       
  1206 
       
  1207     In Qt 3, developers could create a custom event by constructing
       
  1208     a new QCustomEvent, and send relevant data to other components in
       
  1209     the application by passing a void pointer, either on construction or
       
  1210     using the setData() function. Objects could receive custom events
       
  1211     by reimplementing the \l{QObject::customEvent()}{customEvent()}
       
  1212     function, and access the stored data using the event's data()
       
  1213     function.
       
  1214 
       
  1215     In Qt 4, custom events are created by subclassing
       
  1216     QEvent. Event-specific data can be stored in a way that is
       
  1217     appropriate for your application. Custom events are still
       
  1218     delivered to each object's
       
  1219     \l{QObject::customEvent()}{customEvent()} handler function, but as
       
  1220     QEvent objects rather than as deprecated QCustomEvent objects.
       
  1221 
       
  1222     \section1 QDataBrowser
       
  1223 
       
  1224     The \c QDataBrowser class has been renamed Q3DataBrowser and
       
  1225     moved to the Qt3Support library. In Qt 4.2, you should use the
       
  1226     QDataWidgetMapper class to create data-aware forms.
       
  1227 
       
  1228     See \l{QtSql Module} for an overview of the new SQL
       
  1229     classes.
       
  1230 
       
  1231     \section1 QDataPump
       
  1232 
       
  1233     The \c QDataPump class was used internally in Qt 2.x in
       
  1234     conjunction with QImageConsumer. It was obsoleted in Qt 3.0.
       
  1235 
       
  1236     \input porting/porting4-obsoletedmechanism.qdocinc
       
  1237 
       
  1238     \section1 QDataSink
       
  1239 
       
  1240     The \c QDataSink class was used internally in Qt 2.x in conjunction
       
  1241     with QImageConsumer. It was obsoleted in Qt 3.0.
       
  1242 
       
  1243     \input porting/porting4-obsoletedmechanism.qdocinc
       
  1244 
       
  1245     \section1 QDataSource
       
  1246 
       
  1247     The \c QDataSource class was used internally in Qt 2.x in
       
  1248     conjunction with QImageConsumer. It was obsoleted in Qt 3.0.
       
  1249     \input porting/porting4-obsoletedmechanism.qdocinc
       
  1250 
       
  1251     \section1 QDataTable
       
  1252 
       
  1253     The \c QDataTable class has been renamed Q3DataTable and moved to
       
  1254     the Qt3Support library. In Qt 4.2, you should use the
       
  1255     QDataWidgetMapper class to create data-aware forms.
       
  1256 
       
  1257     See \l{QtSql Module} for an overview of the new SQL classes.
       
  1258 
       
  1259     \section1 QDataView
       
  1260 
       
  1261     The \c QDataView class has been renamed Q3DataView and moved to
       
  1262     the Qt3Support library. In Qt 4.2, you should use the
       
  1263     QDataWidgetMapper class to create data-aware forms.
       
  1264 
       
  1265     See \l{QtSql Module} for an overview of the new SQL classes.
       
  1266 
       
  1267     \section1 QDateEdit
       
  1268 
       
  1269     The QDateEdit class in Qt 4 is a convenience class based on
       
  1270     QDateTimeEdit. The old class has been renamed Q3DateEdit and moved
       
  1271     to the Qt3Support library.
       
  1272 
       
  1273     See \l{Porting to Qt 4 - Virtual Functions}{Virtual Functions} for
       
  1274     a list of \c QDateEdit virtual member functions in Qt 3 that are
       
  1275     no longer virtual in Qt 4.
       
  1276 
       
  1277     \section1 QDateTimeEditBase
       
  1278 
       
  1279     The \c QDateTimeEditBase class has been renamed
       
  1280     Q3DateTimeEditBase and moved to Qt3Support. Use QDateTimeEdit or
       
  1281     QAbstractSpinBox instead.
       
  1282 
       
  1283     \section1 QDateTimeEdit
       
  1284 
       
  1285     The old \c QDateTimeEdit class has been renamed
       
  1286     Q3DateTimeEditBase and moved to Qt3Support. The new QDateTimeEdit
       
  1287     in Qt 4 has been rewritten from scratch to provide a more
       
  1288     flexible and powerful API.
       
  1289 
       
  1290     See \l{Porting to Qt 4 - Virtual Functions}{Virtual Functions} for
       
  1291     a list of QDateTimeEdit virtual member functions in Qt 3 that are no
       
  1292     longer virtual in Qt 4.
       
  1293 
       
  1294     \section1 QDeepCopy<T>
       
  1295 
       
  1296     The \c QDeepCopy<T> class in Qt 3 provided a means of ensuring that
       
  1297     implicitly shared and explicitly shared classes referenced unique
       
  1298     data. This was necessary because the reference counting in Qt's
       
  1299     container classes was done in a thread-unsafe manner.
       
  1300 
       
  1301     With Qt 4, \c QDeepCopy<T> has been renamed Q3DeepCopy<T> and
       
  1302     moved to the Qt3Support library. Removing it from
       
  1303     existing code is straightforward.
       
  1304 
       
  1305     \oldcode
       
  1306         QString str1 = "I am a string";
       
  1307         QDeepCopy<QString> str2 = str1;
       
  1308         QString str3 = QDeepCopy<QString>(str2);
       
  1309     \newcode
       
  1310         QString str1 = "I am a string";
       
  1311         QString str2 = str1;
       
  1312         QString str3 = str2;
       
  1313     \endcode
       
  1314 
       
  1315     \section1 QDial
       
  1316 
       
  1317     See \l{Porting to Qt 4 - Virtual Functions}{Virtual Functions} for
       
  1318     a list of QDial virtual member functions in Qt 3 that are no longer
       
  1319     virtual in Qt 4.
       
  1320 
       
  1321     See \l{#properties}{Properties} for a list of QDial properties in
       
  1322     Qt 3 that have changed in Qt 4.
       
  1323 
       
  1324     \target qdict.section
       
  1325     \section1 QDict<T>
       
  1326 
       
  1327     \c QDict<T> has been renamed Q3Dict<T> and moved to Qt3Support.
       
  1328     It has been replaced by the more modern QHash<Key, T> and
       
  1329     QMultiHash<Key, T> classes.
       
  1330 
       
  1331     When porting old code that uses QDict<T> to Qt 4, there are four
       
  1332     classes that you can use:
       
  1333 
       
  1334     \table
       
  1335     \header \o Qt 4 class \o When to use it
       
  1336     \row \o QMultiHash<QString, T *>
       
  1337 
       
  1338          \o Since Q3Dict<T> is pointer-based and allows duplicate
       
  1339             keys, this is usually the most straightforward conversion.
       
  1340 
       
  1341     \row \o QMultiHash<QString, T>
       
  1342 
       
  1343          \o If type \c T is an \l{assignable data type}, you can use
       
  1344             \c T as the value type rather than \c{T *}. This often
       
  1345             leads to nicer code.
       
  1346 
       
  1347     \row \o QHash<QString, T *>
       
  1348 
       
  1349          \o{1,2} If you don't use duplicate keys, you can use QHash
       
  1350             instead of QMultiHash. QMultiHash inherits from QHash.
       
  1351 
       
  1352     \row \o QHash<QString, T>
       
  1353     \endtable
       
  1354 
       
  1355     The APIs of Q3Dict<T> and QMultiHash<QString, T *> are quite
       
  1356     similar. The main issue is that Q3Dict supports auto-delete
       
  1357     whereas QMultiHash doesn't.
       
  1358 
       
  1359     \omit
       
  1360     (See \l{What's Wrong with
       
  1361     Auto-Delete} for an explanation of why the Qt 4 containers don't
       
  1362     offer that feature.)
       
  1363     \endomit
       
  1364 
       
  1365     The following table summarizes the API differences between the
       
  1366     two classes:
       
  1367 
       
  1368     \table
       
  1369     \header \o Q3Dict function \o QMultiHash equivalent
       
  1370     \row \o Q3Dict::Q3Dict(int size, bool caseSensitive) \o See remarks below
       
  1371     \row \o Q3Dict::autoDelete() \o N/A
       
  1372     \row \o Q3Dict::count() \o QMultiHash::count() or QMultiHash::size() (equivalent)
       
  1373     \row \o Q3Dict::find(const QString &) \o QMultiHash::value(const QString &)
       
  1374     \row \o Q3Dict::remove(const QString &) \o QMultiHash::take(const QString &)
       
  1375     \row \o Q3Dict::resize(uint) \o QMultiHash::reserve(int)
       
  1376     \row \o Q3Dict::setAutoDelete() \o See discussion below
       
  1377     \row \o Q3Dict::size() \o QMultiHash::capacity()
       
  1378     \row \o Q3Dict::statistics() \o N/A
       
  1379     \row \o Q3Dict::operator[](const QString &) \o See remark below
       
  1380     \endtable
       
  1381 
       
  1382     Remarks:
       
  1383 
       
  1384     \list 1
       
  1385     \o  Q3Dict requires the user to allocate a specific number of
       
  1386         buckets by passing a prime number (17 by default) to the
       
  1387         constructor and/or calling Q3Dict::resize() later on. In
       
  1388         contrast, QMultiHash's hash table automatically grows and
       
  1389         shrinks as needed, and the constructor doesn't take a prime
       
  1390         number.
       
  1391 
       
  1392     \o  Q3Dict supportes case-insensitive lookups by passing false as
       
  1393         second argument to the constructor. This feature has no
       
  1394         equivalent in QMultiHash. Instead, call QString::toLower()
       
  1395         before you insert or lookup a key in the hash.
       
  1396 
       
  1397     \o  Q3Dict::size() and QMultiHash::size() have different semantics.
       
  1398         The former returns the number of buckets in the container, whereas
       
  1399         the latter returns the number of \e items in the container.
       
  1400 
       
  1401     \o  If there are multiple items with the same key,
       
  1402         Q3Dict::remove() removes only the most recently inserted item,
       
  1403         whereas QMultiHash::remove() removes all items that share a
       
  1404         particular key. To remove only the most recently inserted item,
       
  1405         call QMultiHash::take().
       
  1406 
       
  1407     \o  Q3Dict has only one [] operator (Q3Dict::operator[]()),
       
  1408         providing const access to an item's value. QMultiHash also
       
  1409         has a non-const overload that can be used on the left side of
       
  1410         the assignment operator. If you use the [] operator on a
       
  1411         non-const QHash with an unexisting item, QHash will created
       
  1412         an element and initialize it to be a null pointer. For that
       
  1413         reason, Q3Dict::operator[] should be converted to
       
  1414         QMultiHash::value(), not QMultiHash::operator[].
       
  1415 
       
  1416     \endlist
       
  1417 
       
  1418     If you use Q3Dict's auto-delete feature (by calling
       
  1419     Q3Dict::setAutoDelete(true)), you need to do some more work. You
       
  1420     have two options: Either you call \c delete yourself whenever you
       
  1421     remove an item from the container, or you use
       
  1422     QMultiHash<QString, T> instead of QMultiHash<QString, T *> (i.e.
       
  1423     store values directly instead of pointers to values). Here, we'll
       
  1424     see when to call \c delete.
       
  1425 
       
  1426     The following table summarizes the idioms that you need to watch
       
  1427     out for if you want to call \c delete yourself.
       
  1428 
       
  1429     \table
       
  1430     \header \o Q3Dict idiom \o QMultiHash idiom
       
  1431     \row
       
  1432         \o
       
  1433         \snippet doc/src/snippets/code/doc_src_porting4.qdoc 9
       
  1434         \o
       
  1435         \snippet doc/src/snippets/code/doc_src_porting4.qdoc 10
       
  1436     \row
       
  1437         \o
       
  1438         \snippet doc/src/snippets/code/doc_src_porting4.qdoc 11
       
  1439         \o
       
  1440         \snippet doc/src/snippets/code/doc_src_porting4.qdoc 12
       
  1441     \row
       
  1442         \o
       
  1443         \snippet doc/src/snippets/code/doc_src_porting4.qdoc 13
       
  1444 
       
  1445         (also called from Q3Dict's destructor)
       
  1446 
       
  1447         \o
       
  1448         \snippet doc/src/snippets/code/doc_src_porting4.qdoc 14
       
  1449 
       
  1450         In 99% of cases, the following idiom also works:
       
  1451 
       
  1452         \snippet doc/src/snippets/code/doc_src_porting4.qdoc 15
       
  1453 
       
  1454         However, it may lead to crashes if \c hash is referenced from
       
  1455         the value type's destructor, because \c hash contains
       
  1456         dangling pointers until clear() is called.
       
  1457     \endtable
       
  1458 
       
  1459     Be aware that Q3Dict's destructor automatically calls clear(). If
       
  1460     you have a Q3Dict data member in a custom class and use the
       
  1461     auto-delete feature, you will need to call \c delete on all the
       
  1462     items in the container from your class destructor to avoid a
       
  1463     memory leak.
       
  1464 
       
  1465     Finally, \c QDictIterator<T> (renamed Q3DictIterator<T>) must
       
  1466     also be ported. There are no fewer than four iterator classes
       
  1467     that can be used as a replacement: QHash::const_iterator,
       
  1468     QHash::iterator, QHashIterator, and QMutableHashIterator. The
       
  1469     most straightforward class to use when porting is
       
  1470     QHashIterator<QString, T *>. The following table summarizes the
       
  1471     API differences:
       
  1472 
       
  1473     \table
       
  1474     \header \o Q3DictIterator functions \o Qt 4 equivalent
       
  1475     \row \o Q3DictIterator::count() \o QHash::count() or QHash::size()
       
  1476     \row \o Q3DictIterator::current() \o QHashIterator::value()
       
  1477     \row \o Q3DictIterator::currentKey() \o QHashIterator::key()
       
  1478     \row \o Q3DictIterator::isEmpty() \o QHash::isEmpty()
       
  1479     \row \o Q3DictIterator::toFirst() \o QHashIterator::toFront()
       
  1480     \row \o Q3DictIterator::operator()() \o QHashIterator::value()
       
  1481     \row \o Q3DictIterator::operator*() \o QHashIterator::value()
       
  1482     \row \o Q3DictIterator::operator++() \o See remark below
       
  1483     \endtable
       
  1484 
       
  1485     Be aware that QHashIterator has a different way of iterating than
       
  1486     Q3DictIterator. A typical loop with Q3DictIterator looks like this:
       
  1487 
       
  1488     \snippet doc/src/snippets/code/doc_src_porting4.qdoc 16
       
  1489 
       
  1490     Here's the equivalent QHashIterator loop:
       
  1491 
       
  1492     \snippet doc/src/snippets/code/doc_src_porting4.qdoc 17
       
  1493 
       
  1494     See \l{Java-style iterators} for details.
       
  1495 
       
  1496     \section1 QDir
       
  1497 
       
  1498     The following functions used to have a boolean \c{acceptAbsPath}
       
  1499     parameter that defaulted to true:
       
  1500 
       
  1501     \list
       
  1502     \i QDir::filePath()
       
  1503     \i QDir::absFilePath()
       
  1504     \i QDir::cd()
       
  1505     \i QDir::mkdir()
       
  1506     \i QDir::rmdir()
       
  1507     \i QDir::remove()
       
  1508     \i QDir::rename()
       
  1509     \i QDir::exists()
       
  1510     \endlist
       
  1511 
       
  1512     In Qt 3, if \c acceptAbsPath is true, a file name starting with
       
  1513     '/' is be returned without change; if \c acceptAbsPath is false,
       
  1514     an absolute path is prepended to the file name. For example:
       
  1515 
       
  1516     \table
       
  1517     \header \i Current directory   \i File name        \i \c acceptAbsPath \i File path
       
  1518     \row    \i{1,2} /home/tsmith   \i{1,2} index.html  \i true             \i /home/tsmith/index.html
       
  1519     \row                                               \i false            \i /home/tsmith/index.html
       
  1520     \row    \i{1,2} /home/tsmith   \i{1,2} /index.html \i true             \i /index.html
       
  1521     \row                                               \i false            \i /home/tsmith/index.html
       
  1522     \endtable
       
  1523 
       
  1524     In Qt 4, this parameter is no longer available. If you use it
       
  1525     in your code, you can check that QDir::isRelativePath() returns
       
  1526     false instead.
       
  1527 
       
  1528     \oldcode
       
  1529         QDir dir("/home/tsmith");
       
  1530         QString path = dir.filePath(fileName, false);
       
  1531     \newcode
       
  1532         QDir dir("/home/tsmith");
       
  1533         QString path;
       
  1534         if (dir.isRelativePath(fileName))
       
  1535             path = dir.filePath(fileName);
       
  1536         else
       
  1537             path = fileName;
       
  1538     \endcode
       
  1539 
       
  1540     QDir::encodedEntryList() has been removed.
       
  1541 
       
  1542     fileInfoList(), entryInfoList(), and drives() now return a QList<QFileInfo>
       
  1543     and not a QPtrList<QFileInfo> *. Code using these methods will not work with
       
  1544     the Qt3Support library and must be adapted instead.
       
  1545 
       
  1546     See \l{Porting to Qt 4 - Virtual Functions}{Virtual Functions} for
       
  1547     a list of QDir virtual member functions in Qt 3 that are no longer
       
  1548     virtual in Qt 4.
       
  1549 
       
  1550     QDir::match() now always matches case insensitively.
       
  1551 
       
  1552     QDir::homeDirPath() has been removed. Use QDir::home() instead, and
       
  1553     extract the path separately.
       
  1554 
       
  1555     \section1 QDns
       
  1556 
       
  1557     Qt 3 used its own implementation of the DNS protocol and provided
       
  1558     a low-level \c QDns class. Qt 4's QHostInfo class uses the system's \c
       
  1559     gethostbyname() function from a thread instead.
       
  1560 
       
  1561     The old \c QDns class has been renamed Q3Dns and moved to the
       
  1562     Qt3Support library. The new QHostInfo class has a
       
  1563     radically different API: It consists mainly of two static
       
  1564     functions, one of which is blocking (QHostInfo::fromName()), the
       
  1565     other non-blocking (QHostInfo::lookupHost()). See the QHostInfo
       
  1566     class documentation for details.
       
  1567 
       
  1568     \section1 QDockArea
       
  1569 
       
  1570     The \c QDockArea class has been renamed Q3DockArea and moved to
       
  1571     the Qt3Support library. In Qt 4, QMainWindow handles
       
  1572     the dock and toolbar areas itself. See the QMainWindow
       
  1573     documentation for details.
       
  1574 
       
  1575     \section1 QDockWindow
       
  1576 
       
  1577     The old \c QDockWindow class has been renamed Q3DockWindow and
       
  1578     moved to the Qt3Support library. In Qt 4, there is a
       
  1579     new QDockWidget class with a different API. See the class
       
  1580     documentation for details.
       
  1581 
       
  1582     See \l{Porting to Qt 4 - Virtual Functions}{Virtual Functions} for
       
  1583     a list of QDockWidget virtual member functions in Qt 3 that are no
       
  1584     longer virtual in Qt 4.
       
  1585 
       
  1586     \note \l{Q3DockWindow}'s
       
  1587     \l{Q3DockWindow::setHorizontallyStretchable()}{horizontallyStretchable}
       
  1588     property can be achieved in QDockWidget with
       
  1589     \l{QWidget#Size Hints and Size Policies}{size policies}.
       
  1590 
       
  1591     \section1 QDragObject
       
  1592 
       
  1593     The \c QDragObject class has been renamed Q3DragObject and
       
  1594     moved to the Qt3Support library. In Qt 4, it has been
       
  1595     replaced by the QMimeData class. See the class documentation for
       
  1596     details.
       
  1597 
       
  1598     Note that the Q3DragObject::DragCopyOrMove drag and drop mode is
       
  1599     interpreted differently to Qt 3's QDragObject::DragCopyOrMove mode.
       
  1600     In Qt 3, a move operation was performed by default, and the user had
       
  1601     to hold down the \key{Ctrl} key to perform a copy operation.
       
  1602     In Qt 4, a copy operation is performed by default; the user has to
       
  1603     hold down the \key{Shift} key to perform a move operation.
       
  1604 
       
  1605     See \l{Porting to Qt 4 - Drag and Drop} for a comparison between
       
  1606     the drag and drop APIs in Qt 3 and Qt 4.
       
  1607 
       
  1608     \section1 QDropSite
       
  1609 
       
  1610     The \c QDropSite class has been renamed Q3DropSite and moved to
       
  1611     the Qt3Support library.
       
  1612 
       
  1613     The QDropSite class has been obsolete ever since Qt 2.0. The only
       
  1614     thing it does is call QWidget::setAcceptDrops(true).
       
  1615 
       
  1616     \oldcode
       
  1617     class MyWidget : public QWidget, public QDropSite
       
  1618     {
       
  1619     public:
       
  1620         MyWidget(const QWidget *parent)
       
  1621             : QWidget(parent), QDropSite(this)
       
  1622         {
       
  1623         }
       
  1624         ...
       
  1625     }
       
  1626     \newcode
       
  1627     class MyWidget : public QWidget
       
  1628     {
       
  1629     public:
       
  1630         MyWidget(const QWidget *parent)
       
  1631             : QWidget(parent)
       
  1632         {
       
  1633             setAcceptDrops(true);
       
  1634         }
       
  1635         ...
       
  1636     }
       
  1637     \endcode
       
  1638 
       
  1639     See \l{Porting to Qt 4 - Drag and Drop} for a comparison between
       
  1640     the drag and drop APIs in Qt 3 and Qt 4.
       
  1641 
       
  1642     \section1 QEditorFactory
       
  1643 
       
  1644     The \c QEditorFactory class has been renamed Q3EditorFactory and
       
  1645     moved to the Qt3Support library.
       
  1646 
       
  1647     See \l{QtSql Module} for an overview of the new SQL classes.
       
  1648 
       
  1649     \section1 QEventLoop
       
  1650 
       
  1651     In Qt 3, \c QEventLoop combined the Qt event loop and the event
       
  1652     dispatching. In Qt 4, these tasks are now assigned to two
       
  1653     distinct classes: QEventLoop and QAbstractEventDispatcher.
       
  1654 
       
  1655     If you subclassed QEventLoop to integrate with another library's
       
  1656     event loop, you must subclass QAbstractEventDispatcher instead. See
       
  1657     the class documentation for details.
       
  1658 
       
  1659     Developers using \c{QEventLoop::loopLevel()} in Qt 3 should use
       
  1660     QCoreApplication::loopLevel() instead. Note that this function is
       
  1661     marked as obsolete, but it is expected to be available for the
       
  1662     lifetime of Qt 4.
       
  1663     \omit ### mention virtual functions that aren't virtual anymore \endomit
       
  1664 
       
  1665     \omit
       
  1666     \section1 QFile
       
  1667 
       
  1668     The QFile::readLine(QString&, Q_ULONG) method from qt3 has been removed
       
  1669     in qt4, but this change in the QFile interface is not documented in the
       
  1670     porting documentation as of qt-4.0.0-b1.
       
  1671     \endomit
       
  1672 
       
  1673     \section1 QFileDialog
       
  1674 
       
  1675     The QFileDialog class in Qt 4 has been totally rewritten. It
       
  1676     provides most of the functionality of the old \c QFileDialog
       
  1677     class, but with a different API. Some functionality, such as the
       
  1678     ability to preview files, is expected to be added in a later Qt 4
       
  1679     release.
       
  1680 
       
  1681     The old \c QFileDialog, \c QFileIconProvider, and \c QFilePreview
       
  1682     classes has been renamed Q3FileDialog, Q3FileIconProvider, and
       
  1683     Q3FilePreview and have been moved to Qt3Support. You can use them
       
  1684     if you need some functionality not provided yet by the new
       
  1685     QFileDialog class.
       
  1686 
       
  1687     The following table lists which functions have been renamed or
       
  1688     removed in Qt 4.
       
  1689 
       
  1690     \table
       
  1691     \header \o Old function \o Qt 4 equivalent
       
  1692     \row \o Q3FileDialog::addFilter(const QString &) \o See remark below
       
  1693     \row \o Q3FileDialog::addLeftWidget(QWidget *) \o N/A
       
  1694     \row \o Q3FileDialog::addRightWidget(QWidget *) \o N/A
       
  1695     \row \o Q3FileDialog::addToolButton(QAbstractButton *, bool separator) \o N/A
       
  1696     \row \o Q3FileDialog::addWidgets(QLabel *, QWidget *, QPushButton *) \o N/A
       
  1697     \row \o Q3FileDialog::dir() \o QFileDialog::directory()
       
  1698     \row \o Q3FileDialog::dirPath() \o QFileDialog::directory().path()
       
  1699     \row \o Q3FileDialog::iconProvider() \o N/A
       
  1700     \row \o Q3FileDialog::isContentsPreviewEnabled() \o N/A
       
  1701     \row \o Q3FileDialog::isInfoPreviewEnabled() \o N/A
       
  1702     \row \o Q3FileDialog::previewMode() \o N/A
       
  1703     \row \o Q3FileDialog::rereadDir() \o N/A
       
  1704     \row \o Q3FileDialog::resortDir() \o N/A
       
  1705     \row \o Q3FileDialog::selectAll(bool) \o N/A
       
  1706     \row \o Q3FileDialog::setContentsPreview(QWidget *, Q3FilePreview *) \o N/A
       
  1707     \row \o Q3FileDialog::setContentsPreviewEnabled(bool) \o N/A
       
  1708     \row \o Q3FileDialog::setDir(const QString &) \o QFileDialog::setDirectory(const QString &)
       
  1709     \row \o Q3FileDialog::setFilters(const char **) \o Q3FileDialog::setFilters(const QStringList &)
       
  1710     \row \o Q3FileDialog::setIconProvider(Q3FileIconProvider *) \o N/A
       
  1711     \row \o Q3FileDialog::setInfoPreview(QWidget *, Q3FilePreview *) \o N/A
       
  1712     \row \o Q3FileDialog::setInfoPreviewEnabled(bool) \o N/A
       
  1713     \row \o Q3FileDialog::setPreviewMode(PreviewMode) \o N/A
       
  1714     \row \o Q3FileDialog::setSelectedFilter(const QString &) \o QFileDialog::selectFilter(const QString &)
       
  1715     \row \o Q3FileDialog::setSelectedFilter(int) \o See remark below
       
  1716     \row \o Q3FileDialog::setSelection(const QString &) \o QFileDialog::selectFile(const QString &)
       
  1717     \row \o Q3FileDialog::setShowHiddenFiles(bool) \o showHidden()
       
  1718     \row \o Q3FileDialog::setUrl(const QUrlOperator &) \o N/A
       
  1719     \row \o Q3FileDialog::showHiddenFiles() \o N/A
       
  1720     \row \o Q3FileDialog::url() \o QUrl::fromLocalFile(QFileDialog::directory())
       
  1721     \header \o Old signals \o Qt 4 equivalent
       
  1722     \row \o Q3FileDialog::fileHighlighted(const QString &) \o N/A
       
  1723     \row \o Q3FileDialog::fileSelected(const QString &) \o QFileDialog::filesSelected(const QStringList &)
       
  1724     \row \o Q3FileDialog::dirEntered(const QString &) \o N/A
       
  1725     \row \o Q3FileDialog::filterSelected(const QString &) \o N/A
       
  1726     \endtable
       
  1727 
       
  1728     Remarks:
       
  1729 
       
  1730     \list 1
       
  1731     \o  The Q3FileDialog::addFilter(const QString &) function has no
       
  1732         direct equivalent in the new QFileDialog. Use
       
  1733         QFileDialog::setFilters() instead.
       
  1734 
       
  1735         \oldcode
       
  1736         fileDialog->addFilter(tr("JPEG files (*.jpg *.jpeg)"));
       
  1737         \newcode
       
  1738         QStringList filters = fileDialog->filters();
       
  1739         filters << tr("JPEG files (*.jpg *.jpeg)");
       
  1740         fileDialog->setFilters(filters);
       
  1741         \endcode
       
  1742 
       
  1743     \o  The Q3FileDialog::setSelectedFilter(int) overload has no direct
       
  1744         equivalent in the new QFileDialog. Use
       
  1745         QFileDialog::selectFilter(const QString &) instead.
       
  1746 
       
  1747         \oldcode
       
  1748         fileDialog->setSelectedFilter(3);
       
  1749         \newcode
       
  1750         fileDialog->selectFilter(fileDialog->filters().at(3));
       
  1751         \endcode
       
  1752     \endlist
       
  1753 
       
  1754     There are no equivalent virtual functions to the two
       
  1755     Q3FileDialog::setSelectedFilter() virtual functions in the QFileDialog
       
  1756     API. In addition, these functions have been renamed or removed, as
       
  1757     described above.
       
  1758 
       
  1759     \section1 QFocusData
       
  1760 
       
  1761     The QFocusData class is not available in Qt 4. Some of its
       
  1762     functionality is available via the QWidget::nextInFocusChain()
       
  1763     and QWidget::focusNextPrevChild() functions.
       
  1764 
       
  1765     \section1 QFocusEvent
       
  1766 
       
  1767     The setReason() function is no longer present in Qt 4. It is
       
  1768     necessary to define the reason when constructing a focus event.
       
  1769 
       
  1770     \section1 QFont
       
  1771 
       
  1772     \c QFont::Script has been moved to QFontDatabase::WritingSystem.
       
  1773 
       
  1774     \section1 QFrame
       
  1775 
       
  1776     The QFrame class has been made more lightweight in Qt 4, by
       
  1777     reducing the number of properties and virtual functions. The
       
  1778     reduction in the number of virtual functions is significant
       
  1779     because QFrame is the base class of many Qt classes.
       
  1780 
       
  1781     Here's an overview of the changes:
       
  1782 
       
  1783     \list
       
  1784     \o  QFrame no longer has a \c margin property (which wasn't
       
  1785         honored by Qt's layout managers anyway).
       
  1786 
       
  1787     \o  QFrame no longer has a frameChanged() function, reimplement
       
  1788         QFrame::resizeEvent() instead.
       
  1789 
       
  1790     \o  QFrame used to have drawFrame(QPainter *) and
       
  1791         drawContents(QPainter *) virtual functions. These are now
       
  1792         gone. In Qt 4, the frame is drawn by the QFrame::paintEvent()
       
  1793         function. If you want to change the way QFrame paints itself,
       
  1794         reimplement this function. To draw the contents of the frame,
       
  1795         reimplement QFrame:paintEvent() and call the base class
       
  1796         implementation of the function before you use the
       
  1797         \l {QWidget::}{contentsRect()} function inherited from QWidget,
       
  1798         to retrieve the rectangle to paint on.
       
  1799 
       
  1800     \endlist
       
  1801 
       
  1802     To help with porting, the Qt3Support library contains a Q3Frame
       
  1803     class that inherits QFrame and provides a similar API to the old
       
  1804     QFrame class. If you derived from QFrame in your application, you
       
  1805     might want to use Q3Frame as a base class as a first step in the
       
  1806     porting process, and later move on to the new QFrame class.
       
  1807 
       
  1808     See \l{Porting to Qt 4 - Virtual Functions}{Virtual Functions} for
       
  1809     a list of QFrame virtual member functions in Qt 3 that are no longer
       
  1810     virtual in Qt 4.
       
  1811 
       
  1812     \section1 QFtp
       
  1813 
       
  1814     QFtp no longer inherits from QNetworkProtocol. See the
       
  1815     \l{#qnetworkprotocol.section}{section on QNetworkProtocol} for
       
  1816     details.
       
  1817 
       
  1818     The old \c QFtp class has been renamed Q3Ftp and moved to the
       
  1819     Qt3Support library.
       
  1820 
       
  1821     \target qglayoutiterator.section
       
  1822     \section1 QGLayoutIterator
       
  1823 
       
  1824     The QGLayoutIterator class no longer exists in Qt 4. This makes
       
  1825     only a difference if you implemented custom layout managers
       
  1826     (i.e., QLayout subclasses).
       
  1827 
       
  1828     The new approach is much simpler: It consists in reimplementing
       
  1829     QLayout::itemAt() and QLayout::takeAt(). These functions operate
       
  1830     on indexes, eliminating the need for a layout iterator class.
       
  1831 
       
  1832     \section1 QGrid
       
  1833 
       
  1834     The \c QGrid class is now only available as Q3Grid in Qt 4. You
       
  1835     can achieve the same result as \c QGrid by creating a QWidget
       
  1836     with a grid layout:
       
  1837 
       
  1838     \oldcode
       
  1839     QGrid *grid = new QGrid(2, Qt::Horizontal);
       
  1840     QPushButton *child1 = new QPushButton(grid);
       
  1841     QPushButton *child2 = new QPushButton(grid);
       
  1842     QPushButton *child3 = new QPushButton(grid);
       
  1843     QPushButton *child4 = new QPushButton(grid);
       
  1844     \newcode
       
  1845     QWidget *grid = new QWidget;
       
  1846     QPushButton *child1 = new QPushButton(grid);
       
  1847     QPushButton *child2 = new QPushButton(grid);
       
  1848     QPushButton *child3 = new QPushButton(grid);
       
  1849     QPushButton *child4 = new QPushButton(grid);
       
  1850 
       
  1851     QVBoxLayout *layout = new QVBoxLayout;
       
  1852     layout->addWidget(child1, 0, 0);
       
  1853     layout->addWidget(child2, 0, 1);
       
  1854     layout->addWidget(child3, 1, 0);
       
  1855     layout->addWidget(child4, 1, 1);
       
  1856     grid->setLayout(layout);
       
  1857     \endcode
       
  1858 
       
  1859     \section1 QGridLayout
       
  1860 
       
  1861     See \l{Porting to Qt 4 - Virtual Functions}{Virtual Functions} for
       
  1862     a list of QGridLayout virtual member functions in Qt 3 that are no
       
  1863     longer virtual in Qt 4.
       
  1864 
       
  1865     \section1 QGridView
       
  1866 
       
  1867     The \c QGridView class has been renamed Q3GridView and moved to
       
  1868     the Qt3Support library. In Qt 4, we recommend that
       
  1869     you use QTableView or QAbstractItemView for presenting tabular
       
  1870     data.
       
  1871 
       
  1872     See \l{Model/View Programming} for an overview of the new item
       
  1873     view classes.
       
  1874 
       
  1875     \target qgroupbox.section
       
  1876     \section1 QGroupBox
       
  1877 
       
  1878     The QGroupBox class has been redesigned in Qt 4. Many of the
       
  1879     features of the old \c QGroupBox class can be obtained by using
       
  1880     the Q3GroupBox class from the Qt3Support library.
       
  1881 
       
  1882     The new QGroupBox is more lightweight. It doesn't attempt to
       
  1883     duplicate functionality already provided by QGridLayout, and it
       
  1884     does not inherit from QFrame. As a result, the following members
       
  1885     have been removed:
       
  1886 
       
  1887     \list
       
  1888     \o Q3GroupBox::setColumns(), Q3GroupBox::columns()
       
  1889     \o Q3GroupBox::setOrientation(), Q3GroupBox::orientation()
       
  1890     \o Q3GroupBox::setInsideMargin(), Q3GroupBox::insideMargin()
       
  1891     \o Q3GroupBox::addSpace()
       
  1892     \endlist
       
  1893 
       
  1894     Naturally, the \c columns and \c orientation properties have also
       
  1895     been removed.
       
  1896 
       
  1897     If you rely on some of the missing functionality in your
       
  1898     application, you can use Q3GroupBox instead of QGroupBox as a
       
  1899     help to porting.
       
  1900 
       
  1901     See \l{Porting to Qt 4 - Virtual Functions}{Virtual Functions} for
       
  1902     a list of QGroupBox virtual member functions in Qt 3 that are no
       
  1903     longer virtual in Qt 4.
       
  1904 
       
  1905     \section1 QHBox
       
  1906 
       
  1907     The \c QHBox class is now only available as Q3HBox in Qt 4. You
       
  1908     can achieve the same result as \c QHBox by creating a QWidget
       
  1909     with an horizontal layout:
       
  1910 
       
  1911     \oldcode
       
  1912     QHBox *hbox = new QHBox;
       
  1913     QPushButton *child1 = new QPushButton(hbox);
       
  1914     QPushButton *child2 = new QPushButton(hbox);
       
  1915     \newcode
       
  1916     QWidget *hbox = new QWidget;
       
  1917     QPushButton *child1 = new QPushButton;
       
  1918     QPushButton *child2 = new QPushButton;
       
  1919 
       
  1920     QHBoxLayout *layout = new QHBoxLayout;
       
  1921     layout->addWidget(child1);
       
  1922     layout->addWidget(child2);
       
  1923     hbox->setLayout(layout);
       
  1924     \endcode
       
  1925 
       
  1926     Note that child widgets are not automatically placed into the widget's
       
  1927     layout; you will need to manually add each widget to the QHBoxLayout.
       
  1928 
       
  1929     \section1 QHeader
       
  1930 
       
  1931     The \c QHeader class has been renamed Q3Header and moved to
       
  1932     the Qt3Support library. In Qt 4, it is replaced
       
  1933     by the QHeaderView class.
       
  1934 
       
  1935     See \l{Model/View Programming} for an overview of the new item
       
  1936     view classes.
       
  1937 
       
  1938     \section1 QHGroupBox
       
  1939 
       
  1940     The \c QHGroupBox class has been renamed Q3HGroupBox and moved to
       
  1941     the Qt3Support library.
       
  1942     Qt 4 does not provide a specific replacement class for \c QHGroupBox
       
  1943     since QGroupBox is designed to be a generic container widget. As a
       
  1944     result, you need to supply your own layout for any child widgets.
       
  1945 
       
  1946     See \l{#QGroupBox} for more information about porting code that uses
       
  1947     group boxes.
       
  1948 
       
  1949     \section1 QHttp
       
  1950 
       
  1951     QHttp no longer inherits from QNetworkProtocol. See the See the
       
  1952     \l{#qnetworkprotocol.section}{section on QNetworkProtocol} for
       
  1953     details.
       
  1954 
       
  1955     The old \c QHttp, \c QHttpHeader, \c QHttpRequestHeader, and \c
       
  1956     QHttpResponseHeader classes have been renamed Q3Http,
       
  1957     Q3HttpHeader, Q3HttpRequestHeader, and Q3HttpResponseHeader  and
       
  1958     have been moved to the Qt3Support library.
       
  1959 
       
  1960     \section1 QIconFactory
       
  1961 
       
  1962     The QIconFactory class is no longer part of Qt. It has been replaced by
       
  1963     the QIconEngine class.
       
  1964 
       
  1965     \section1 QIconSet
       
  1966 
       
  1967     The QIconSet class is no longer part of Qt. It has been replaced by
       
  1968     the QIcon class.
       
  1969 
       
  1970     \section1 QIconView
       
  1971 
       
  1972     The \c QIconView, \c QIconViewItem, \c QIconDrag, and \c
       
  1973     QIconDragItem classes has been renamed Q3IconView,
       
  1974     Q3IconViewItem, Q3IconDrag, and Q3IconDragItem and moved to the
       
  1975     Qt3Support library. New Qt applications should use
       
  1976     QListWidget or its base class QListView instead, and call
       
  1977     QListView::setViewMode(QListView::IconMode) to obtain an "icon
       
  1978     view" look.
       
  1979 
       
  1980     See \l{Model/View Programming} for an overview of the new item
       
  1981     view classes.
       
  1982 
       
  1983     \omit
       
  1984     ###
       
  1985 
       
  1986     \section1 QImage
       
  1987 
       
  1988     QImage::fromMimeSource(const QString &) -> qImageFromMimeSource(const QString &)
       
  1989     \endomit
       
  1990 
       
  1991     \section1 QImageDrag
       
  1992 
       
  1993     The \c QImageDrag class has been renamed Q3ImageDrag and moved to
       
  1994     the Qt3Support library. In Qt 4, use QMimeData
       
  1995     instead and call QMimeData::setImage() to set the image.
       
  1996 
       
  1997     See \l{Porting to Qt 4 - Drag and Drop} for a comparison between
       
  1998     the drag and drop APIs in Qt 3 and Qt 4.
       
  1999 
       
  2000     \section1 QImageIO
       
  2001 
       
  2002     The \c QImageIO class has been split into two classes:
       
  2003     QImageReader and QImageWriter. The table below shows the
       
  2004     correspondance between the two APIs:
       
  2005 
       
  2006     \table
       
  2007     \header \o Qt 3 function              \o Qt 4 equivalents
       
  2008     \row    \o QImageIO::description()    \o QImageWriter::text()
       
  2009     \row    \o QImageIO::fileName()       \o QImageReader::fileName() and QImageWriter::fileName()
       
  2010     \row    \o QImageIO::format()         \o QImageReader::format() and QImageWriter::format()
       
  2011     \row    \o QImageIO::gamma()          \o QImageWriter::gamma()
       
  2012     \row    \o QImageIO::image()          \o Return value of QImageReader::read()
       
  2013     \row    \o QImageIO::inputFormats()   \o QImageReader::supportedImageFormats()
       
  2014     \row    \o QImageIO::ioDevice()       \o QImageReader::device() and QImageWriter::device()
       
  2015     \row    \o QImageIO::outputFormats()  \o QImageWriter::supportedImageFormats()
       
  2016     \row    \o QImageIO::parameters()     \o N/A
       
  2017     \row    \o QImageIO::quality()        \o QImageWriter::quality()
       
  2018     \row    \o QImageIO::read()           \o QImageReader::read()
       
  2019     \row    \o QImageIO::setDescription() \o QImageWriter::setText()
       
  2020     \row    \o QImageIO::setFileName()    \o QImageReader::setFileName() and QImageWriter::setFileName()
       
  2021     \row    \o QImageIO::setFormat()      \o QImageReader::setFormat() and QImageWriter::setFormat()
       
  2022     \row    \o QImageIO::setGamma()       \o QImageWriter::setGamma()
       
  2023     \row    \o QImageIO::setIODevice()    \o QImageReader::setDevice() and QImageWriter::setDevice()
       
  2024     \row    \o QImageIO::setImage()       \o Argument to QImageWriter::write()
       
  2025     \row    \o QImageIO::setParameters()  \o N/A
       
  2026     \row    \o QImageIO::setQuality()     \o QImageWriter::setQuality()
       
  2027     \row    \o QImageIO::setStatus()      \o N/A
       
  2028     \row    \o QImageIO::status()         \o QImageReader::error() and QImageWriter::error()
       
  2029     \row    \o QImageIO::write()          \o QImageWriter::write()
       
  2030     \endtable
       
  2031 
       
  2032     \section1 QIntCache<T>
       
  2033 
       
  2034     QIntCache<T> has been moved to Qt3Support. It has been replaced
       
  2035     by QCache<int, T>.
       
  2036 
       
  2037     For details, read the \l{#qcache.section}{section on QCache<T>},
       
  2038     mentally substituting \c int for QString.
       
  2039 
       
  2040     \section1 QIntDict<T>
       
  2041 
       
  2042     QIntDict<T> and QIntDictIterator<T> have been moved to
       
  2043     Qt3Support. They have been replaced by the more modern QHash<Key,
       
  2044     T> and QMultiHash<Key, T> classes and their associated iterator
       
  2045     classes.
       
  2046 
       
  2047     When porting old code that uses QIntDict<T> to Qt 4, there are
       
  2048     four classes that you can use:
       
  2049 
       
  2050     \list
       
  2051     \o QMultiHash<int, T *>
       
  2052     \o QMultiHash<int, T>
       
  2053     \o QHash<int, T *>
       
  2054     \o QHash<int, T>
       
  2055     \endlist
       
  2056 
       
  2057     For details, read the \l{#qdict.section}{section on QDict<T>},
       
  2058     mentally substituting \c int for QString.
       
  2059 
       
  2060     \target qiodevice.section
       
  2061     \section1 QIODevice
       
  2062 
       
  2063     The QIODevice class's API has been simplified to make it easier
       
  2064     to subclass and to make it work more smoothly with asynchronous
       
  2065     devices such as QTcpSocket and QProcess.
       
  2066 
       
  2067     The following virtual functions have changed name or signature:
       
  2068 
       
  2069     \table
       
  2070     \header \o Qt 3 function \o Comment
       
  2071     \row \o QIODevice::at() const \o Renamed QIODevice::pos().
       
  2072     \row \o QIODevice::at(Offset) \o Renamed QIODevice::seek().
       
  2073     \row \o QIODevice::open(int) \o The parameter is now of type QIODevice::OpenMode.
       
  2074     \row \o QIODevice::readBlock(char *, Q_ULONG) \o QIODevice::read(char *, qint64)
       
  2075     \row \o QIODevice::writeBlock(const char *, Q_ULONG) \o QIODevice::write(const char *, qint64)
       
  2076     \endtable
       
  2077 
       
  2078     \note QIODevice::open(QIODevice::OpenMode) is no longer pure virtual.
       
  2079 
       
  2080     The following functions are no longer virtual or don't exist anymore:
       
  2081 
       
  2082     \table
       
  2083     \row \o QIODevice::getch() \o Renamed QIODevice::getChar() and implemented in terms of QIODevice::readData().
       
  2084     \row \o QIODevice::putch(int) \o Renamed QIODevice::putChar() and implemented in terms of QIODevice::writeData().
       
  2085     \row \o QIODevice::readAll() \o Implemented in terms of QIODevice::readData().
       
  2086     \row \o QIODevice::readLine(char *, Q_ULONG) \o Implemented in terms of QIODevice::readData()
       
  2087     \row \o QIODevice::ungetch(int) \o Renamed QIODevice::ungetChar() and simulated using an internal unget buffer.
       
  2088     \endtable
       
  2089 
       
  2090     The \c IO_xxx flags have been revised, and the protected setFlags()
       
  2091     function removed. Most of the flags have been
       
  2092     eliminated because errors are best handled by implementing certain
       
  2093     functions in QIODevice subclasses rather than through the base classes.
       
  2094     The file access flags, such as \c IO_ReadOnly and \c IO_WriteOnly, have
       
  2095     been moved to the QIODevice class to avoid polluting the global
       
  2096     namespace. The table below shows the correspondence between the
       
  2097     Qt 3 \c IO_xxx flags and the Qt 4 API:
       
  2098 
       
  2099     \table
       
  2100     \header \o Qt 3 constant \o Qt 4 equivalent
       
  2101     \row \o IO_Direct \o Use !QIODevice::isSequential() instead (notice the \e not).
       
  2102     \row \o IO_Sequential \o Use QIODevice::isSequential() instead.
       
  2103     \row \o IO_Combined \o N/A
       
  2104     \row \o IO_TypeMask \o N/A
       
  2105     \row \o IO_Raw \o QIODevice::Unbuffered
       
  2106     \row \o IO_Async \o N/A
       
  2107     \row \o IO_ReadOnly \o QIODevice::ReadOnly
       
  2108     \row \o IO_WriteOnly \o QIODevice::WriteOnly
       
  2109     \row \o IO_ReadWrite \o QIODevice::ReadWrite
       
  2110     \row \o IO_Append \o QIODevice::Append
       
  2111     \row \o IO_Truncate \o QIODevice::Truncate
       
  2112     \row \o IO_Translate \o QIODevice::Text
       
  2113     \row \o IO_ModeMask \o N/A
       
  2114     \row \o IO_Open \o Use QIODevice::isOpen() instead.
       
  2115     \row \o IO_StateMask \o N/A
       
  2116     \row \o IO_Ok \o N/A
       
  2117     \row \o IO_ReadError \o N/A
       
  2118     \row \o IO_WriteError \o N/A
       
  2119     \row \o IO_FatalError \o N/A
       
  2120     \row \o IO_ResourceError \o N/A
       
  2121     \row \o IO_OpenError \o N/A
       
  2122     \row \o IO_ConnectError \o N/A
       
  2123     \row \o IO_AbortError \o N/A
       
  2124     \row \o IO_TimeOutError \o N/A
       
  2125     \row \o IO_UnspecifiedError \o N/A
       
  2126     \endtable
       
  2127 
       
  2128     \section1 QIODeviceSource
       
  2129 
       
  2130     The QIODeviceSource class was used internally in Qt 2.x in
       
  2131     conjunction with QImageConsumer. It was obsoleted in Qt 3.0.
       
  2132     \input porting/porting4-obsoletedmechanism.qdocinc
       
  2133 
       
  2134     \section1 QLabel
       
  2135 
       
  2136     QLabel doesn't enable word-wrap automatically anymore when rich
       
  2137     text is used. You can enable it by calling
       
  2138     QLabel::setWordWrap() or by setting the
       
  2139     \l{QLabel::wordWrap}{wordWrap} property. The reason for this
       
  2140     change is that the old behavior was confusing to many users.
       
  2141 
       
  2142     Also, QLabel no longer offers an \c autoResize property. Instead,
       
  2143     you can call QWidget::setFixedSize() on the label, with
       
  2144     QLabel::sizeHint() as the argument, whenever you change the
       
  2145     contents of the QLabel.
       
  2146 
       
  2147     See also \l{Porting to Qt 4 - Virtual Functions}{Virtual Functions}
       
  2148     for a list of QLabel virtual member functions in Qt 3 that are no
       
  2149     longer virtual in Qt 4.
       
  2150 
       
  2151     \section1 QLayout
       
  2152 
       
  2153     In Qt 4, margins are always handled by layouts; there is no
       
  2154     QLayout::setSupportsMargin() function anymore.
       
  2155 
       
  2156     The deleteAllItems() function is now only available if
       
  2157     \c QT3_SUPPORT is defined. If you maintain a QList of layout
       
  2158     items, you can use qDeleteAll() to remove all the items in one
       
  2159     go.
       
  2160 
       
  2161     In Qt 3, it was possible to change the resizing behavior for layouts
       
  2162     in top-level widgets by adjusting the layout's \c resizeMode property.
       
  2163     In Qt 4, this property has been replaced by the QLayout::sizeConstraint
       
  2164     property which provides more control over how the layout behaves when
       
  2165     resized.
       
  2166 
       
  2167     See also the \l{#qlayoutiterator.section}{section on
       
  2168     QLayoutIterator} and the \l{#qglayoutiterator.section}{section on
       
  2169     QGLayoutIterator}.
       
  2170 
       
  2171     \target qlayoutiterator.section
       
  2172     \section1 QLayoutIterator
       
  2173 
       
  2174     The QLayoutIterator class is obsoleted in Qt 4. It is available
       
  2175     only if \c QT3_SUPPORT is defined. It can be replaced by the
       
  2176     QLayout::itemAt() and QLayout::takeAt() functions, which operate
       
  2177     on indexes.
       
  2178 
       
  2179     \oldcode
       
  2180         QLayoutIterator it = layout()->iterator();
       
  2181         QLayoutItem *child;
       
  2182         while ((child = it.current()) != 0) {
       
  2183             if (child->widget() == myWidget) {
       
  2184                 it.takeCurrent();
       
  2185                 return;
       
  2186             ++it;
       
  2187         }
       
  2188     \newcode
       
  2189         int i = 0;
       
  2190         QLayoutItem *child;
       
  2191         while ((child = layout()->itemAt(i)) != 0) {
       
  2192             if (child->widget() == myWidget) {
       
  2193                 layout()->takeAt(i);
       
  2194                 return;
       
  2195             }
       
  2196             ++i;
       
  2197         }
       
  2198     \endcode
       
  2199 
       
  2200     \section1 QLineEdit
       
  2201 
       
  2202     See \l{#properties}{Properties} for a list of QLineEdit
       
  2203     properties in Qt 3 that have changed in Qt 4.
       
  2204 
       
  2205     The default value of QLineEdit's \l{QLineEdit::dragEnabled()}{dragEnabled}
       
  2206     property was \c true in Qt 3. In Qt 4, the default value is \c false.
       
  2207 
       
  2208     Note that QLineEdit in Qt 4 is no longer a subclass of QFrame.
       
  2209     If you need to visually style a line edit with a frame, we recommend
       
  2210     either using a QFrame as a container for a QLineEdit or customizing
       
  2211     the line edit with a \l{Qt Style Sheets}{style sheet}.
       
  2212 
       
  2213     \section1 QListBox
       
  2214 
       
  2215     The \c QListBox, \c QListBoxItem, \c QListBoxText, and \c
       
  2216     QListBoxPixmap classes have been renamed Q3ListBox,
       
  2217     Q3ListBoxItem, Q3ListBoxText, and Q3ListBoxPixmap and have been
       
  2218     moved to the Qt3Support library. New Qt applications
       
  2219     should use QListWidget or its base class QListView instead.
       
  2220 
       
  2221     See \l{Model/View Programming} for an overview of the new item
       
  2222     view classes.
       
  2223 
       
  2224     \section1 QListView
       
  2225 
       
  2226     The \c QListView, \c QListViewItem, \c QCheckListItem, and \c
       
  2227     QListViewItemIterator classes have been renamed Q3ListView,
       
  2228     Q3ListViewItem, Q3CheckListItem, and Q3ListViewItemIterator, and
       
  2229     have been moved to the Qt3Support library. New Qt
       
  2230     applications should use one of the following four classes
       
  2231     instead: QTreeView or QTreeWidget for tree-like structures;
       
  2232     QListWidget or the new QListView class for one-dimensional lists.
       
  2233 
       
  2234     See \l{Model/View Programming} for an overview of the new item
       
  2235     view classes.
       
  2236 
       
  2237     \section1 QLocalFs
       
  2238 
       
  2239     The \c QLocalFs class is no longer part of the public Qt API. It
       
  2240     has been renamed Q3LocalFs and moved to Qt3Support. Use QDir,
       
  2241     QFileInfo, or QFile instead.
       
  2242 
       
  2243     \section1 QMainWindow
       
  2244 
       
  2245     The QMainWindow class has been redesigned in Qt 4 to provide a
       
  2246     more modern look and feel and more flexibility. The API has
       
  2247     changed to reflect that. The old \c QMainWindow class has been
       
  2248     renamed Q3MainWindow and moved to Qt3Support. See the QMainWindow
       
  2249     class documentation for details.
       
  2250 
       
  2251     \omit ### More detail \endomit
       
  2252 
       
  2253     \target qmemarray.section
       
  2254     \section1 QMemArray<T>
       
  2255 
       
  2256     QMemArray<T> has been moved to Qt3Support. It has been replaced
       
  2257     by the QVector<T> class.
       
  2258 
       
  2259     The following table summarizes the API differences between the
       
  2260     two classes.
       
  2261 
       
  2262     \table
       
  2263     \row \o QMemArray::assign(const QMemArray<T> &) \o QVector::operator=()
       
  2264     \row \o QMemArray::assign(const T *, uint) \o See remark below
       
  2265     \row \o QMemArray::duplicate(const QMemArray &) \o QVector::operator=()
       
  2266     \row \o QMemArray::duplicate(const T *, uint) \o See remark below
       
  2267     \row \o QMemArray::setRawData(const T *, uint) \o N/A
       
  2268     \row \o QMemArray::resetRawData(const T *, uint) \o N/A
       
  2269     \row \o QMemArray::find(const T &, uint) \o QVector::indexOf(const T &, int)
       
  2270     \row \o QMemArray::contains(const T &) \o QVector::count(const T &)
       
  2271     \row \o QMemArray::sort() \o \l qSort()
       
  2272     \row \o QMemArray::bsearch(const T &d) \o \l qBinaryFind()
       
  2273     \row \o QMemArray::at(uint) \o QVector::operator[]()
       
  2274     \row \o QMemArray::operator const T *() \o QVector::constData()
       
  2275     \endtable
       
  2276 
       
  2277     Remarks:
       
  2278 
       
  2279     \list 1
       
  2280     \o  QMemArray::assign(const T *, uint) and QMemArray::duplicate(const T *, uint)
       
  2281         can be replaced by QVector::resize() and qCopy().
       
  2282 
       
  2283         \oldcode
       
  2284         QMemArray<QSize> array;
       
  2285         ...
       
  2286         array.assign(data, size);
       
  2287         \newcode
       
  2288         QVector<QSize> vector;
       
  2289         ...
       
  2290         vector.resize(size);
       
  2291         qCopy(data, data + size, vector.begin());
       
  2292         \endcode
       
  2293 
       
  2294     \o  QMemArray is an explicitly shared class, whereas QVector is
       
  2295         implicitly shared. See \l{Explicit Sharing} for more
       
  2296         information.
       
  2297     \endlist
       
  2298 
       
  2299     \section1 QMenuBar
       
  2300 
       
  2301     In Qt 3, QMenuBar inherited from QFrame and QMenuData; in Qt 4, it is
       
  2302     a direct subclass of QWidget. Applications that provided customized
       
  2303     menu bars will need to take advantage of the styling features described
       
  2304     in the \l{Qt Style Sheets} document.
       
  2305 
       
  2306     It is not possible to add widgets to menu bars in Qt 4.
       
  2307 
       
  2308     \section1 QMenuData
       
  2309 
       
  2310     In Qt 4, the QMenu class provides a menu widget that can be used in all
       
  2311     the places where menus are used in an application. Unlike \c QMenuData,
       
  2312     QMenu is designed around the concept of actions, provided by the QAction
       
  2313     class, instead of the identifiers used in Qt 3.
       
  2314 
       
  2315     In Qt 3, it was possible to insert widgets directly into menus by using
       
  2316     a specific \c QMenuData::insertItem() overload. In Qt 4.2 and later,
       
  2317     the QWidgetAction class can be used to wrap widgets for use in Qt 4's
       
  2318     action-based APIs.
       
  2319 
       
  2320     \section1 QMessageBox
       
  2321 
       
  2322     The QMessageBox::iconPixmap() function used to return a "const
       
  2323     QPixmap *". In Qt 4, it returns a QPixmap.
       
  2324 
       
  2325     \section1 QMimeSourceFactory
       
  2326 
       
  2327     The \c QMimeSourceFactory has been renamed Q3MimeSourceFactory
       
  2328     and moved to the Qt3Support library. New Qt applications should
       
  2329     use Qt 4's \l{Resource System} instead.
       
  2330 
       
  2331     \section1 QMovie
       
  2332 
       
  2333     The QMovie API has been revised in Qt 4 to make it more
       
  2334     consistent with the other Qt classes (notably QImageReader). The
       
  2335     table below summarizes the changes.
       
  2336 
       
  2337     \table
       
  2338     \header \o Qt 3 function \o Qt 4 equivalent
       
  2339     \row \o QMovie::connectResize() \o Connect to QMovie::resized()
       
  2340     \row \o QMovie::connectStatus() \o Connect to QMovie::stateChanged()
       
  2341     \row \o QMovie::connectUpdate() \o Connect to QMovie::updated()
       
  2342     \row \o QMovie::disconnectResize() \o Disconnect from QMovie::resized()
       
  2343     \row \o QMovie::disconnectStatus() \o Disconnect from QMovie::stateChanged()
       
  2344     \row \o QMovie::disconnectUpdate() \o Disconnect from QMovie::updated()
       
  2345     \row \o QMovie::finished() \o Use QMovie::state() instead
       
  2346     \row \o QMovie::frameImage() \o Use QMovie::currentImage() instead
       
  2347     \row \o QMovie::frameNumber() \o Use QMovie::currentFrameNumber() instead
       
  2348     \row \o QMovie::framePixmap() \o Use QMovie::currentPixmap() instead
       
  2349     \row \o QMovie::getValidRect() \o Use frameRect() instead
       
  2350     \row \o QMovie::isNull() \o Use QMovie::isValid() instead
       
  2351     \row \o QMovie::pause() \o Use QMovie::setPaused(true) instead
       
  2352     \row \o QMovie::paused() \o Use QMovie::state() instead
       
  2353     \row \o QMovie::pushData() \o N/A
       
  2354     \row \o QMovie::pushSpace() \o N/A
       
  2355     \row \o QMovie::restart() \o Use QMovie::jumpToFrame(0) instead
       
  2356     \row \o QMovie::running() \o Use QMovie::state() instead
       
  2357     \row \o QMovie::step() \o Use QMovie::jumpToFrame() and QMovie::setPaused() instead
       
  2358     \row \o QMovie::step() \o Use QMovie::jumpToNextFrame() instead
       
  2359     \row \o QMovie::steps() \o Use QMovie::currentFrameNumber() and QMovie::frameCount() instead
       
  2360     \row \o QMovie::unpause() \o Use QMovie::setPaused(false) instead
       
  2361     \endtable
       
  2362 
       
  2363     \section1 QMultiLineEdit
       
  2364 
       
  2365     The \c QMultiLineEdit class in Qt 3 was a convenience QTextEdit
       
  2366     subclass that provided an interface compatible with Qt 2's
       
  2367     QMultiLineEdit class. In Qt 4, it is called Q3MultiLineEdit, it
       
  2368     inherits Q3TextEdit, and it is part of Qt3Support. Use QTextEdit
       
  2369     in new code.
       
  2370 
       
  2371     \target qnetworkprotocol.section
       
  2372     \section1 QNetworkProtocol
       
  2373 
       
  2374     The QNetworkProtocol, QNetworkProtocolFactoryBase,
       
  2375     QNetworkProtocolFactory<T>, and QNetworkOperation classes are no
       
  2376     longer part of the public Qt API. They have been renamed
       
  2377     Q3NetworkProtocol, Q3NetworkProtocolFactoryBase,
       
  2378     Q3NetworkProtocolFactory<T>, and Q3NetworkOperation and have been
       
  2379     moved to the Qt3Support library.
       
  2380 
       
  2381     In Qt 4 applications, you can use classes like QFtp and
       
  2382     QNetworkAccessManager directly to perform file-related actions on
       
  2383     a remote host.
       
  2384 
       
  2385     \section1 QObject
       
  2386 
       
  2387     QObject::children() now returns a QObjectList instead of a
       
  2388     pointer to a QObjectList. See also the comments on QObjectList
       
  2389     below.
       
  2390 
       
  2391     Use QObject::findChildren() (or qFindChildren() if you need MSVC 6
       
  2392     compatibility) instead of QObject::queryList(). For example:
       
  2393 
       
  2394     \snippet doc/src/snippets/code/doc_src_porting4.qdoc 18
       
  2395 
       
  2396     QObject::killTimers() has been removed because it was unsafe to
       
  2397     use in subclass. (A subclass normally doesn't know whether the
       
  2398     base class uses timers or not.)
       
  2399 
       
  2400     The \c QObject::name property has been renamed
       
  2401     QObject::objectName.
       
  2402 
       
  2403     \c QObject::objectTrees() has been removed. If you are primarly
       
  2404     interested in widgets, use QApplication::allWidgets() or
       
  2405     QApplication::topLevelWidgets().
       
  2406 
       
  2407     \section1 QObjectDictionary
       
  2408 
       
  2409     The QObjectDictionary class is a synonym for
       
  2410     QAsciiDict<QMetaObject>. See the \l{#qasciidict.section}{section
       
  2411     on QAsciiDict<T>}.
       
  2412 
       
  2413     \section1 QObjectList
       
  2414 
       
  2415     In Qt 3, the QObjectList class was a typedef for
       
  2416     QPtrList<QObject>. In Qt 4, it is a typedef for QList<QObject *>.
       
  2417     See the \l{#qptrlist.section}{section on QPtrList<T>}.
       
  2418 
       
  2419     \section1 QPaintDevice
       
  2420 
       
  2421     To reimplement painter backends one previously needed to reimplement
       
  2422     the virtual function QPaintDevice::cmd(). This function is taken out
       
  2423     and should is replaced with the function QPaintDevice::paintEngine()
       
  2424     and the abstract class QPaintEngine. QPaintEngine provides virtual
       
  2425     functions for all drawing operations that can be performed on a
       
  2426     painter backend.
       
  2427 
       
  2428     bitBlt() and copyBlt() are now only compatibility functions. Use
       
  2429     QPainter::drawPixmap() instead.
       
  2430 
       
  2431     \section1 QPaintDeviceMetrics
       
  2432 
       
  2433     All functions that used to be provided by the \c
       
  2434     QPaintDeviceMetrics class have now been moved to QPaintDevice.
       
  2435 
       
  2436     \oldcode
       
  2437         QPaintDeviceMetrics metrics(widget);
       
  2438         int deviceDepth = metrics.depth();
       
  2439     \newcode
       
  2440         int deviceDepth = widget->depth();
       
  2441     \endcode
       
  2442 
       
  2443     For compatibility, the old \c QPaintDeviceMetrics class has been
       
  2444     renamed Q3PaintDeviceMetrics and moved to Qt3Support.
       
  2445 
       
  2446     \section1 QPainter
       
  2447 
       
  2448     The QPainter class has undergone some changes in Qt 4 because of
       
  2449     the way rectangles are drawn. In Qt 4, the result of drawing a
       
  2450     QRect with a pen width of 1 pixel is 1 pixel wider and 1 pixel
       
  2451     taller than in Qt 3.
       
  2452 
       
  2453     For compatibility, we provide a Q3Painter class in Qt3Support
       
  2454     that provides the old semantics. See the Q3Painter documentation
       
  2455     for details and for the reasons why we had to make this change.
       
  2456 
       
  2457     The \l{http://qt.nokia.com/doc/3.3/qpainter.html#CoordinateMode-enum}{QPainter::CoordinateMode}
       
  2458     enum has been removed in Qt 4. All clipping
       
  2459     operations are now defined using logical coordinates and are subject
       
  2460     to transformation operations.
       
  2461 
       
  2462     The
       
  2463     \l{http://qt.nokia.com/doc/3.3/qpainter.html#RasterOP-enum}{QPainter::RasterOP}
       
  2464     enum has been replaced with QPainter::CompositionMode.
       
  2465 
       
  2466     \section1 QPicture
       
  2467 
       
  2468     In Qt 3, a QPicture could be saved in the SVG file format. In Qt
       
  2469     4, the SVG support is provided by the QtSvg module, which
       
  2470     includes classes for \e displaying the contents of SVG files.
       
  2471 
       
  2472     If you would like to generate SVG files, you can use the Q3Picture
       
  2473     compatibility class or the QSvgGenerator class introduced in Qt 4.3.
       
  2474 
       
  2475     \section1 QPixmap
       
  2476 
       
  2477     The mask() function has been changed to return a reference to a QBitmap
       
  2478     rather than a pointer. As a result, it is no longer possible simply to
       
  2479     test for a null pointer when determining whether a pixmap has a mask.
       
  2480     Instead, you need to explicitly test whether the mask bitmap is null or
       
  2481     not.
       
  2482 
       
  2483     \oldcode
       
  2484         if (pixmap.mask())
       
  2485             widget->setMask(*pixmap.mask());
       
  2486     \newcode
       
  2487         if (!pixmap.mask().isNull())
       
  2488             widget->setMask(pixmap.mask());
       
  2489     \endcode
       
  2490 
       
  2491     The \c QPixmap::setOptimization() and \c QPixmap::setDefaultOptimization()
       
  2492     mechanism is no longer available in Qt 4.
       
  2493 
       
  2494 \omit
       
  2495     QPixmap::fromMimeSource(const QString &) -> qPixmapFromMimeSource(const QString &)
       
  2496 \endomit
       
  2497 
       
  2498     \section1 QPointArray
       
  2499 
       
  2500     The \c QPointArray class has been renamed QPolygon in Qt 4 and
       
  2501     has undergone significant changes. In Qt 3, \c QPointArray
       
  2502     inherited from QMemArray<QPoint>. In Qt 4, QPolygon inherits from
       
  2503     QVector<QPoint>. Everything mentioned in the
       
  2504     \l{#qmemarray.section}{section on QMemArray<T>} apply for
       
  2505     QPointArray as well.
       
  2506 
       
  2507     The Qt3Support library contains a Q3PointArray class
       
  2508     that inherits from QPolygon and provides a few functions that
       
  2509     existed in \c QPointArray but no longer exist in QPolygon. These
       
  2510     functions include Q3PointArray::makeArc(),
       
  2511     Q3PointArray::makeEllipse(), and Q3PointArray::cubicBezier().
       
  2512     In Qt 4, we recommend that you use QPainterPath for representing
       
  2513     arcs, ellipses, and Bezier curves, rather than QPolygon.
       
  2514 
       
  2515     The QPolygon::setPoints() and QPolygon::putPoints() functions
       
  2516     return \c void in Qt 4. The corresponding Qt 3 functions returned
       
  2517     a \c bool indicating whether the array was successfully resized
       
  2518     or not. This can now be checked by checking QPolygon::size()
       
  2519     after the call.
       
  2520 
       
  2521 \omit
       
  2522     X11 Specific:
       
  2523 
       
  2524     ::appDisplay() -> QX11Info::display()
       
  2525     QPaintDevice::x11Display() -> QX11Info::display()
       
  2526     QPaintDevice::x11AppDisplay() -> QX11Info::display()
       
  2527     QPaintDevice::x11Screen() -> QX11Info::appScreen()
       
  2528     QPaintDevice::x11AppScreen() -> ???
       
  2529     QPaintDevice::x11Depth() -> QX11Info::appDepth()
       
  2530     QPaintDevice::x11ColorMap() -> QX11Info::appColorMap()
       
  2531     QPaintDevice::x11DefaultColorMap() -> ???
       
  2532     QPaintDevice::x11Visual() -> QX11Info::appVisual()
       
  2533     QPaintDevice::x11DefaultVisual() -> ???
       
  2534 
       
  2535     QPaintDevice::x11AppDpiX() -> QX11Info::appDpiX()
       
  2536     QPaintDevice::x11AppDpiY() -> QX11Info::appDpiY()
       
  2537     QPaintDevice::x11SetAppDpiX() -> QX11Info::setAppDpiX()
       
  2538     QPaintDevice::x11SetAppDpiY() -> QX11Info::setAppDpiY()
       
  2539 
       
  2540     QPaintDevice::x11AppDepth() -> ???
       
  2541     QPaintDevice::x11AppCells() -> ???
       
  2542     QPaintDevice::x11AppRootWindow() -> ???
       
  2543     QPaintDevice::x11AppColorMap() -> ???
       
  2544     QPaintDevice::x11AppDefaultColorMap() -> ???
       
  2545     QPaintDevice::x11AppVisual() -> ???
       
  2546     QPaintDevice::x11AppDefaultVisual() -> ???
       
  2547 
       
  2548     End of X11 Specific
       
  2549 \endomit
       
  2550 
       
  2551     \section1 QPopupMenu
       
  2552 
       
  2553     For most purposes, QPopupMenu has been replaced by QMenu in Qt
       
  2554     4. For compatibility with older applications, Q3PopupMenu provides
       
  2555     the old API and features that are specific to pop-up menus. Note
       
  2556     that, when using Q3PopupMenu, the menu's actions must be \l
       
  2557     {Q3Action}s.
       
  2558 
       
  2559     In Qt 3, it was common practice to add entries to pop-up menus using the
       
  2560     insertItem() function, maintaining identifiers for future use; for
       
  2561     example, to dynamically change menu items.
       
  2562     In Qt 4, menu entries are completely represented
       
  2563     by actions for consistency with other user interface components, such as
       
  2564     toolbar buttons. Create new menus with the QMenu class, and use the
       
  2565     overloaded QMenu::addAction() functions to insert new entries.
       
  2566     If you need to manage a set of actions created for a particular menu,
       
  2567     we suggest that you construct a QActionGroup and add them to that.
       
  2568 
       
  2569     The \l{Main Window Examples} provided
       
  2570     show how to use Qt's action system to construct menus, toolbars, and other
       
  2571     common user interface elements.
       
  2572 
       
  2573     \section1 QPrinter
       
  2574 
       
  2575     The QPrinter class now expects printing to be set up from a
       
  2576     QPrintDialog.
       
  2577 
       
  2578     \section1 QProcess
       
  2579 
       
  2580     The QProcess class has undergone major improvements in Qt 4. It
       
  2581     now inherits QIODevice, which makes it possible to combine
       
  2582     QProcess with a QTextStream or a QDataStream.
       
  2583 
       
  2584     The old \c QProcess class has been renamed Q3Process and moved to
       
  2585     the Qt3Support library.
       
  2586 
       
  2587     \section1 QProgressBar
       
  2588 
       
  2589     The QProgressBar API has been significantly improved in Qt 4. The
       
  2590     old \c QProgressBar API is available as Q3ProgressBar in the
       
  2591     Qt3Support library.
       
  2592 
       
  2593     \section1 QProgressDialog
       
  2594 
       
  2595     The QProgressDialog API has been significantly improved in Qt 4.
       
  2596     The old \c QProgressDialog API is available as Q3ProgressDialog
       
  2597     in the Qt3Support library.
       
  2598 
       
  2599     See \l{#properties}{Properties} for a list of QProgressDialog
       
  2600     properties in Qt 3 that have changed in Qt 4.
       
  2601 
       
  2602     \section1 QPtrCollection<T>
       
  2603 
       
  2604     The \c QPtrCollection<T> abstract base class has been renamed
       
  2605     Q3PtrCollection<T> moved to the Qt3Support library.
       
  2606     There is no direct equivalent in Qt 4.
       
  2607 
       
  2608     \omit
       
  2609     ###
       
  2610     The QPtrCollection entry is unsatisfactory. The xref is missing
       
  2611     its list and saying "no direct equivalent" with so suggestions
       
  2612     seems feeble.
       
  2613     \endomit
       
  2614 
       
  2615     See \l{Generic Containers} for a list of Qt 4 containers.
       
  2616 
       
  2617     \section1 QPtrDict<T>
       
  2618 
       
  2619     \c QPtrDict<T> and \c QPtrDictIterator<T> have been renamed
       
  2620     Q3PtrDict<T> and Q3PtrDictIterator<T> and have been moved to the
       
  2621     Qt3Support library. They have been replaced by the
       
  2622     more modern QHash<Key, T> and QMultiHash<Key, T> classes and
       
  2623     their associated iterator classes.
       
  2624 
       
  2625     When porting old code that uses Q3PtrDict<T> to Qt 4, there are
       
  2626     four classes that you can use:
       
  2627 
       
  2628     \list
       
  2629     \o QMultiHash<void *, T *>
       
  2630     \o QMultiHash<void *, T>
       
  2631     \o QHash<void *, T *>
       
  2632     \o QHash<void *, T>
       
  2633     \endlist
       
  2634 
       
  2635     (You can naturally use other types than \c{void *} for the key
       
  2636     type, e.g. \c{QWidget *}.)
       
  2637 
       
  2638     To port Q3PtrDict<T> to Qt 4, read the \l{#qdict.section}{section
       
  2639     on QDict<T>}, mentally substituting \c{void *} for QString.
       
  2640 
       
  2641     \target qptrlist.section
       
  2642     \section1 QPtrList<T>
       
  2643 
       
  2644     QPtrList<T>, QPtrListIterator<T>, and QPtrListStdIterator<T> have
       
  2645     been moved to the Qt3Support library. They have been
       
  2646     replaced by the more modern QList and QLinkedList classes and
       
  2647     their associated iterator classes.
       
  2648 
       
  2649     When porting to Qt 4, you have the choice of using QList<T> or
       
  2650     QLinkedList<T> as alternatives to QValueList<T>. QList<T> has an
       
  2651     index-based API and provides very fast random access
       
  2652     (QList::operator[]), whereas QLinkedList<T> has an iterator-based
       
  2653     API.
       
  2654 
       
  2655     The following table summarizes the API differences between
       
  2656     QPtrList<T> and QList<T *>:
       
  2657 
       
  2658     \table
       
  2659     \header \o QPtrList function \o QList equivalent
       
  2660     \row \o QPtrList::contains(const T *) \o QList::count(T *)
       
  2661     \row \o QPtrList::containsRef(const T *) \o QList::count(T *)
       
  2662     \row \o QPtrList::find(const T *) \o See remark below
       
  2663     \row \o QPtrList::findRef(const T *) \o See remark below
       
  2664     \row \o QPtrList::getFirst() \o QList::first()
       
  2665     \row \o QPtrList::getLast() \o QList::last()
       
  2666     \row \o QPtrList::inSort(const T *) \o N/A
       
  2667     \row \o QPtrList::remove(const T *) \o QList::removeAll(T *)
       
  2668     \row \o QPtrList::remove(uint) \o QList::removeAt(int)
       
  2669     \row \o QPtrList::removeNode(QLNode *) \o N/A
       
  2670     \row \o QPtrList::removeRef(const T *) \o QList::removeAll(T *)
       
  2671     \row \o QPtrList::sort() \o See remark below
       
  2672     \row \o QPtrList::takeNode(QLNode *) \o N/A
       
  2673     \row \o QPtrList::toVector(QGVector *) \o See remark below
       
  2674     \endtable
       
  2675 
       
  2676     Remarks:
       
  2677 
       
  2678     \list 1
       
  2679     \o  QPtrList::toVector(QGVector *) can be replaced by
       
  2680         QVector::resize() and qCopy().
       
  2681 
       
  2682         \oldcode
       
  2683         QPtrList<QWidget> list;
       
  2684         ...
       
  2685         QPtrVector<QWidget> vector;
       
  2686         list.toVector(&vector);
       
  2687         \newcode
       
  2688         QList<QWidget *> list;
       
  2689         ...
       
  2690         QVector<QWidget *> vector;
       
  2691         vector.resize(list.size());
       
  2692         qCopy(list.begin(), list.end(), vector.begin());
       
  2693         \endcode
       
  2694 
       
  2695     \o  QPtrList::sort() relied on the virtual compareItems() to
       
  2696         sort items. In Qt 4, you can use \l qSort() instead and pass
       
  2697         your "compare item" function as an argument.
       
  2698 
       
  2699     \o  QPtrList::find(const T *) returns an iterator, whereas
       
  2700         QList::indexOf(T *) returns an index. To convert an index
       
  2701         into an iterator, add the index to QList::begin().
       
  2702 
       
  2703     \o  QPtrList::removeFirst() and QPtrList::removeLast() return a \c
       
  2704         bool that indicates whether the element was removed or not.
       
  2705         The corresponding QList functions return \c void. You can
       
  2706         achieve the same result by calling QList::isEmpty() before
       
  2707         attempting to remove an item.
       
  2708     \endlist
       
  2709 
       
  2710     If you use QPtrList's auto-delete feature (by calling
       
  2711     QPtrList::setAutoDelete(true)), you need to do some more work.
       
  2712     You have two options: Either you call \c delete yourself whenever
       
  2713     you remove an item from the container, or you can use QList<T>
       
  2714     instead of QList<T *> (i.e. store values directly instead of
       
  2715     pointers to values). Here, we'll see when to call \c delete.
       
  2716 
       
  2717     \omit
       
  2718     (See \l{What's Wrong with Auto-Delete} for an explanation of why
       
  2719     the Qt 4 containers don't offer that feature.)
       
  2720     \endomit
       
  2721 
       
  2722     The following table summarizes the idioms that you need to watch
       
  2723     out for if you want to call \c delete yourself.
       
  2724 
       
  2725     \table
       
  2726     \header \o QPtrList idiom \o QList idiom
       
  2727     \row
       
  2728         \o
       
  2729         \snippet doc/src/snippets/code/doc_src_porting4.qdoc 19
       
  2730         \o
       
  2731         \snippet doc/src/snippets/code/doc_src_porting4.qdoc 20
       
  2732     \row
       
  2733         \o
       
  2734         \snippet doc/src/snippets/code/doc_src_porting4.qdoc 21
       
  2735         \o
       
  2736         \snippet doc/src/snippets/code/doc_src_porting4.qdoc 22
       
  2737     \row
       
  2738         \o
       
  2739         \snippet doc/src/snippets/code/doc_src_porting4.qdoc 23
       
  2740         \o
       
  2741         \snippet doc/src/snippets/code/doc_src_porting4.qdoc 24
       
  2742     \row
       
  2743         \o
       
  2744         \snippet doc/src/snippets/code/doc_src_porting4.qdoc 25
       
  2745         \o
       
  2746         \snippet doc/src/snippets/code/doc_src_porting4.qdoc 26
       
  2747     \row
       
  2748         \o
       
  2749         \snippet doc/src/snippets/code/doc_src_porting4.qdoc 27
       
  2750         \o
       
  2751         \snippet doc/src/snippets/code/doc_src_porting4.qdoc 28
       
  2752     \row
       
  2753         \o
       
  2754         \snippet doc/src/snippets/code/doc_src_porting4.qdoc 29
       
  2755         (removes the current item)
       
  2756 
       
  2757         \o
       
  2758         \snippet doc/src/snippets/code/doc_src_porting4.qdoc 30
       
  2759     \row
       
  2760         \o
       
  2761         \snippet doc/src/snippets/code/doc_src_porting4.qdoc 31
       
  2762 
       
  2763         (also called from QPtrList's destructor)
       
  2764 
       
  2765         \o
       
  2766         \snippet doc/src/snippets/code/doc_src_porting4.qdoc 32
       
  2767 
       
  2768         In 99% of cases, the following idiom also works:
       
  2769 
       
  2770         \snippet doc/src/snippets/code/doc_src_porting4.qdoc 33
       
  2771 
       
  2772         However, it may lead to crashes if \c list is referenced from
       
  2773         the value type's destructor, because \c list contains
       
  2774         dangling pointers until clear() is called.
       
  2775     \endtable
       
  2776 
       
  2777     Be aware that QPtrList's destructor automatically calls clear().
       
  2778     If you have a QPtrList data member in a custom class and use the
       
  2779     auto-delete feature, you will need to call \c delete on all the
       
  2780     items in the container from your class destructor to avoid a
       
  2781     memory leak.
       
  2782 
       
  2783     QPtrList had the concept of a "current item", which could be used
       
  2784     for traversing the list without using an iterator. When porting
       
  2785     to Qt 4, you can use the Java-style QListIterator<T *> (or
       
  2786     QMutableListIterator<T *>) class instead. The following table
       
  2787     summarizes the API differences:
       
  2788 
       
  2789     \table
       
  2790     \header \o QPtrList function \o QListIterator equivalent
       
  2791     \row \o QPtrList::at() \o N/A
       
  2792     \row \o QPtrList::current() \o QMutableListIterator::value()
       
  2793     \row \o QPtrList::currentNode() \o N/A
       
  2794     \row \o QPtrList::findNext(const T *) \o QListIterator::findNext(const T *)
       
  2795     \row \o QPtrList::findNextRef(const T *) \o QListIterator::findNext(const T *)
       
  2796     \row \o QPtrList::first() \o QPtrList::toFront()
       
  2797     \row \o QPtrList::last() \o QPtrList::toBack()
       
  2798     \row \o QPtrList::next() \o QPtrList::next()
       
  2799     \row \o QPtrList::prev() \o QPtrList::previous()
       
  2800     \row \o QPtrList::remove() \o QMutableListIterator::remove()
       
  2801     \row \o QPtrList::take() \o QMutableListIterator::remove()
       
  2802     \endtable
       
  2803 
       
  2804     Be aware that QListIterator has a different way of iterating than
       
  2805     QPtrList. A typical loop with QPtrList looks like this:
       
  2806 
       
  2807     \snippet doc/src/snippets/code/doc_src_porting4.qdoc 34
       
  2808 
       
  2809     Here's the equivalent QListIterator loop:
       
  2810 
       
  2811     \snippet doc/src/snippets/code/doc_src_porting4.qdoc 35
       
  2812 
       
  2813     Finally, QPtrListIterator<T> must also be ported. There are no
       
  2814     fewer than four iterator classes that can be used as a
       
  2815     replacement: QList::const_iterator, QList::iterator,
       
  2816     QListIterator, and QMutableListIterator. The most straightforward
       
  2817     class to use when porting is QMutableListIterator<T *> (if you
       
  2818     modify the list through the iterator) or QListIterator<T *> (if
       
  2819     you don't). The following table summarizes the API differences:
       
  2820 
       
  2821     \table
       
  2822     \header \o QPtrListIterator function \o Qt 4 equivalent
       
  2823     \row \o QPtrListIterator::atFirst() \o !QListIterator::hasPrevious() (notice the \c{!})
       
  2824     \row \o QPtrListIterator::atLast() \o !QListIterator::hasNext() (notice the \c{!})
       
  2825     \row \o QPtrListIterator::count() \o QList::count() or QList::size()
       
  2826     \row \o QPtrListIterator::current() \o QMutableListIterator::value()
       
  2827     \row \o QPtrListIterator::isEmpty() \o QList::isEmpty()
       
  2828     \row \o QPtrListIterator::toFirst() \o QListIterator::toFront()
       
  2829     \row \o QPtrListIterator::toLast() \o QListIterator::toBack()
       
  2830     \row \o QPtrListIterator::operator() \o QMutableListIterator::value()
       
  2831     \row \o QPtrListIterator::operator*() \o QMutableListIterator::value()
       
  2832     \endtable
       
  2833 
       
  2834     Again, be aware that QListIterator has a different way of
       
  2835     iterating than QPtrList. A typical loop with QPtrList looks like
       
  2836     this:
       
  2837 
       
  2838     \snippet doc/src/snippets/code/doc_src_porting4.qdoc 36
       
  2839 
       
  2840     Here's the equivalent QListIterator loop:
       
  2841 
       
  2842     \snippet doc/src/snippets/code/doc_src_porting4.qdoc 37
       
  2843 
       
  2844     Finally, QPtrListStdIterator<T> must also be ported. This is
       
  2845     easy, because QList also provides STL-style iterators
       
  2846     (QList::iterator and QList::const_iterator).
       
  2847 
       
  2848     \section1 QPtrQueue<T>
       
  2849 
       
  2850     QPtrQueue has been moved to the Qt3Support library.
       
  2851     It has been replaced by the more modern QQueue class.
       
  2852 
       
  2853     The following table summarizes the differences between
       
  2854     QPtrQueue<T> and QQueue<T *>:
       
  2855 
       
  2856     \table
       
  2857     \header \o QPtrQueue function \o QQueue equivalent
       
  2858     \row \o QPtrQueue::autoDelete() \o See discussion below
       
  2859     \row \o QPtrQueue::count() \o QQueue::count() or QQueue::size() (equivalent)
       
  2860     \row \o QPtrQueue::current() \o QQueue::head()
       
  2861     \row \o QPtrQueue::remove() \o QQueue::dequeue()
       
  2862     \row \o QPtrQueue::setAutoDelete() \o See discussion below
       
  2863     \endtable
       
  2864 
       
  2865     If you use QPtrQueue's auto-delete feature (by calling
       
  2866     QPtrQueue::setAutoDelete(true)), you need to do some more work.
       
  2867     You have two options: Either you call \c delete yourself whenever
       
  2868     you remove an item from the container, or you can use QQueue<T>
       
  2869     instead of QQueue<T *> (i.e. store values directly instead of
       
  2870     pointers to values). Here, we will show when to call \c delete.
       
  2871 
       
  2872     \omit
       
  2873     (See \l{What's Wrong with Auto-Delete} for an explanation of why
       
  2874     the Qt 4 containers don't offer that feature.)
       
  2875     \endomit
       
  2876 
       
  2877     \table
       
  2878     \header \o QPtrQueue idiom \o QQueue idiom
       
  2879     \row
       
  2880         \o
       
  2881         \snippet doc/src/snippets/code/doc_src_porting4.qdoc 38
       
  2882         \o
       
  2883         \snippet doc/src/snippets/code/doc_src_porting4.qdoc 39
       
  2884     \row
       
  2885         \o
       
  2886         \snippet doc/src/snippets/code/doc_src_porting4.qdoc 40
       
  2887         \o
       
  2888         \snippet doc/src/snippets/code/doc_src_porting4.qdoc 41
       
  2889     \row
       
  2890         \o
       
  2891         \snippet doc/src/snippets/code/doc_src_porting4.qdoc 42
       
  2892 
       
  2893         (also called from QPtrQueue's destructor)
       
  2894 
       
  2895         \o
       
  2896         \snippet doc/src/snippets/code/doc_src_porting4.qdoc 43
       
  2897 
       
  2898         In 99% of cases, the following idiom also works:
       
  2899 
       
  2900         \snippet doc/src/snippets/code/doc_src_porting4.qdoc 44
       
  2901 
       
  2902         However, it may lead to crashes if \c queue is referenced
       
  2903         from the value type's destructor, because \c queue contains
       
  2904         dangling pointers until clear() is called.
       
  2905     \endtable
       
  2906 
       
  2907     \section1 QPtrStack<T>
       
  2908 
       
  2909     QPtrStack has been moved to the Qt3Support library.
       
  2910     It has been replaced by the more modern QStack class.
       
  2911 
       
  2912     The following table summarizes the differences between
       
  2913     QPtrStack<T> and QStack<T *>:
       
  2914 
       
  2915     \table
       
  2916     \header \o QPtrStack function \o QStack equivalent
       
  2917     \row \o QPtrStack::autoDelete() \o See discussion below
       
  2918     \row \o QPtrStack::count() \o QStack::count() or QStack::size() (equivalent)
       
  2919     \row \o QPtrStack::current() \o QStack::top()
       
  2920     \row \o QPtrStack::remove() \o QStack::pop()
       
  2921     \row \o QPtrStack::setAutoDelete() \o See discussion below
       
  2922     \endtable
       
  2923 
       
  2924     If you use QPtrStack's auto-delete feature (by calling
       
  2925     QPtrStack::setAutoDelete(true)), you need to do some more work.
       
  2926     You have two options: Either you call \c delete yourself whenever
       
  2927     you remove an item from the container, or you can use QStack<T>
       
  2928     instead of QStack<T *> (i.e. store values directly instead of
       
  2929     pointers to values). Here, we will show when to call \c delete.
       
  2930 
       
  2931     \omit
       
  2932     (See \l{What's Wrong with Auto-Delete} for an explanation of why
       
  2933     the Qt 4 containers don't offer that feature.)
       
  2934     \endomit
       
  2935 
       
  2936     \table
       
  2937     \header \o QPtrStack idiom \o QStack idiom
       
  2938     \row
       
  2939         \o
       
  2940         \snippet doc/src/snippets/code/doc_src_porting4.qdoc 45
       
  2941         \o
       
  2942         \snippet doc/src/snippets/code/doc_src_porting4.qdoc 46
       
  2943     \row
       
  2944         \o
       
  2945         \snippet doc/src/snippets/code/doc_src_porting4.qdoc 47
       
  2946         \o
       
  2947         \snippet doc/src/snippets/code/doc_src_porting4.qdoc 48
       
  2948     \row
       
  2949         \o
       
  2950         \snippet doc/src/snippets/code/doc_src_porting4.qdoc 49
       
  2951 
       
  2952         (also called from QPtrStack's destructor)
       
  2953 
       
  2954         \o
       
  2955         \snippet doc/src/snippets/code/doc_src_porting4.qdoc 50
       
  2956 
       
  2957         In 99% of cases, the following idiom also works:
       
  2958 
       
  2959         \snippet doc/src/snippets/code/doc_src_porting4.qdoc 51
       
  2960 
       
  2961         However, it may lead to crashes if \c stack is referenced
       
  2962         from the value type's destructor, because \c stack contains
       
  2963         dangling pointers until clear() is called.
       
  2964     \endtable
       
  2965 
       
  2966     \section1 QPtrVector<T>
       
  2967 
       
  2968     QPtrVector<T> has been moved to Qt3Support. It has been replaced
       
  2969     by the more modern QVector class.
       
  2970 
       
  2971     When porting to Qt 4, you can use QVector<T *> as an alternative
       
  2972     to QPtrVector<T>. The APIs of QPtrVector<T> and QVector<T *> are
       
  2973     somewhat similar. The main issue is that QPtrVector supports
       
  2974     auto-delete whereas QVector doesn't.
       
  2975 
       
  2976     \omit
       
  2977     (See \l{What's Wrong with Auto-Delete} for an explanation of why
       
  2978     the Qt 4 containers don't offer that feature.)
       
  2979     \endomit
       
  2980 
       
  2981     The following table summarizes the API differences between the
       
  2982     two classes:
       
  2983 
       
  2984     \table
       
  2985     \header \o QPtrVector function \o QVector equivalent
       
  2986     \row \o QPtrVector::autoDelete() \o See discussion below
       
  2987     \row \o QPtrVector::bsearch(const T *) \o \l qBinaryFind()
       
  2988     \row \o QPtrVector::contains(const T *) \o QVector::count(T *)
       
  2989     \row \o QPtrVector::containsRef(const T *) \o QVector::count(T *)
       
  2990     \row \o QPtrVector::count() \o See remark below
       
  2991     \row \o QPtrVector::insert(uint, T *) \o See remark below
       
  2992     \row \o QPtrVector::isNull() \o N/A
       
  2993     \row \o QPtrVector::remove(uint) \o See remark below
       
  2994     \row \o QPtrVector::setAutoDelete() \o See discussion below
       
  2995     \row \o QPtrVector::sort() \o \l qSort()
       
  2996     \row \o QPtrVector::take(uint) \o See remark below
       
  2997     \row \o QPtrVector::toList(QGList *) \o QList::QList(const QVector &)
       
  2998     \endtable
       
  2999 
       
  3000     Remarks:
       
  3001 
       
  3002     \list 1
       
  3003     \o  QPtrVector::insert(uint, T *) sets an item to store a certain
       
  3004         pointer value. This is \e not the same as QVector::insert(int, T *),
       
  3005         which creates space for the item by moving following items by
       
  3006         one position. Use \c{vect[i] = ptr} to set a QVector item to
       
  3007         a particular value.
       
  3008     \o  QPtrVector::remove(uint) sets an item to be 0. This is \e not
       
  3009         the same as QVector::removeAt(int), which entirely erases the
       
  3010         item, reducing the size of the vector. Use \c{vect[i] = 0} to
       
  3011         set a QVector item to 0.
       
  3012     \o  Likewise, QPtrVector::take(uint) sets an item to be 0 and
       
  3013         returns the previous value of the item. Again, this is easy to
       
  3014         achieve using QVector::operator[]().
       
  3015     \o  QPtrVector::count() returns the number of non-null items in
       
  3016         the vector, whereas QVector::count() (like QVector::size())
       
  3017         returns the number of items (null or non-null) in the vector.
       
  3018         Fortunately, it's not too hard to simulate QPtrVector::count().
       
  3019 
       
  3020         \oldcode
       
  3021         int numValidItems = vect.count();
       
  3022         \newcode
       
  3023         int numValidItems = vect.size() - vect.count(0);
       
  3024         \endcode
       
  3025     \endlist
       
  3026 
       
  3027     If you use QVector's auto-delete feature (by calling
       
  3028     QVector::setAutoDelete(true)), you need to do some more work. You
       
  3029     have two options: Either you call \c delete yourself whenever you
       
  3030     remove an item from the container, or you use QVector<T> instead
       
  3031     of QVector<T *> (i.e. store values directly instead of pointers
       
  3032     to values). Here, we'll see when to call \c delete.
       
  3033 
       
  3034     The following table summarizes the idioms that you need to watch
       
  3035     out for if you want to call \c delete yourself.
       
  3036 
       
  3037     \table
       
  3038     \header \o QPtrVector idiom \o QVector idiom
       
  3039     \row
       
  3040         \o
       
  3041         \snippet doc/src/snippets/code/doc_src_porting4.qdoc 52
       
  3042         \o
       
  3043         \snippet doc/src/snippets/code/doc_src_porting4.qdoc 53
       
  3044     \row
       
  3045         \o
       
  3046         \snippet doc/src/snippets/code/doc_src_porting4.qdoc 54
       
  3047         \o
       
  3048         \snippet doc/src/snippets/code/doc_src_porting4.qdoc 55
       
  3049     \row
       
  3050         \o
       
  3051         \snippet doc/src/snippets/code/doc_src_porting4.qdoc 56
       
  3052         \o
       
  3053         \snippet doc/src/snippets/code/doc_src_porting4.qdoc 57
       
  3054     \row
       
  3055         \o
       
  3056         \snippet doc/src/snippets/code/doc_src_porting4.qdoc 58
       
  3057         \o
       
  3058         \snippet doc/src/snippets/code/doc_src_porting4.qdoc 59
       
  3059     \row
       
  3060         \o
       
  3061         \snippet doc/src/snippets/code/doc_src_porting4.qdoc 60
       
  3062 
       
  3063         (also called from QPtrVector's destructor)
       
  3064 
       
  3065         \o
       
  3066         \snippet doc/src/snippets/code/doc_src_porting4.qdoc 61
       
  3067 
       
  3068         In 99% of cases, the following idiom also works:
       
  3069 
       
  3070         \snippet doc/src/snippets/code/doc_src_porting4.qdoc 62
       
  3071 
       
  3072         However, it may lead to crashes if \c vect is referenced from
       
  3073         the value type's destructor, because \c vect contains
       
  3074         dangling pointers until clear() is called.
       
  3075     \endtable
       
  3076 
       
  3077     Be aware that QPtrVector's destructor automatically calls
       
  3078     clear(). If you have a QPtrVector data member in a custom class
       
  3079     and use the auto-delete feature, you will need to call \c delete
       
  3080     on all the items in the container from your class destructor to
       
  3081     avoid a memory leak.
       
  3082 
       
  3083     \section1 QPushButton
       
  3084 
       
  3085     See \l{#properties}{Properties} for a list of QPushButton
       
  3086     properties in Qt 3 that have changed in Qt 4.
       
  3087 
       
  3088     \section1 QRangeControl
       
  3089 
       
  3090     In Qt 3, various "range control" widgets (QDial, QScrollBar,
       
  3091     QSlider, and QSpin) inherited from both QWidget and
       
  3092     \c QRangeControl.
       
  3093 
       
  3094     In Qt 4, \c QRangeControl has been replaced with the new
       
  3095     QAbstractSlider and QAbstractSpinBox classes, which inherit from
       
  3096     QWidget and provides similar functionality. Apart from eliminating
       
  3097     unnecessary multiple inheritance, the new design allows
       
  3098     QAbstractSlider to provide signals, slots, and properties.
       
  3099 
       
  3100     The old \c QRangeControl class has been renamed Q3RangeControl
       
  3101     and moved to the Qt3Support library, together with
       
  3102     the (undocumented) \c QSpinWidget class.
       
  3103 
       
  3104     If you use \c QRangeControl as a base class in your application,
       
  3105     you can switch to use QAbstractSlider or QAbstractSpinBox instead.
       
  3106 
       
  3107     \oldcode
       
  3108         class VolumeControl : public QWidget, public QRangeControl
       
  3109         {
       
  3110             ...
       
  3111         protected:
       
  3112             void valueChange() {
       
  3113                 update();
       
  3114                 emit valueChanged(value());
       
  3115             }
       
  3116             void rangeChange() {
       
  3117                 update();
       
  3118             }
       
  3119             void stepChange() {
       
  3120                 update();
       
  3121             }
       
  3122         };
       
  3123     \newcode
       
  3124         class VolumeControl : public QAbstractSlider
       
  3125         {
       
  3126             ...
       
  3127         protected:
       
  3128             void sliderChange(SliderChange change) {
       
  3129                 update();
       
  3130                 if (change == SliderValueChange)
       
  3131                     emit valueChanged(value());
       
  3132             }
       
  3133         };
       
  3134     \endcode
       
  3135 
       
  3136     \section1 QRegExp
       
  3137 
       
  3138     The search() and searchRev() functions have been renamed to indexIn()
       
  3139     and lastIndexIn() respectively.
       
  3140 
       
  3141     \section1 QRegion
       
  3142 
       
  3143     The following changes have been made to QRegion in Qt 4:
       
  3144 
       
  3145     \list
       
  3146     \o  There is no longer any difference between a \e null region and
       
  3147         an \e empty region. Use isEmpty() in most places where you
       
  3148         would have used a null QRegion.
       
  3149     \o  QRegion::rects() used to return a QMemArray<QRect>. It now returns
       
  3150         a QVector<QRect>.
       
  3151     \endlist
       
  3152 
       
  3153     \section1 QScrollBar
       
  3154 
       
  3155     See \l{#properties}{Properties} for a list of QScrollBar
       
  3156     properties in Qt 3 that have changed in Qt 4.
       
  3157 
       
  3158     \section1 QScrollView
       
  3159 
       
  3160     The \c QScrollView class has been renamed Q3ScrollView and moved
       
  3161     to the Qt3Support library. It has been replaced by
       
  3162     the QAbstractScrollArea and QScrollArea classes.
       
  3163 
       
  3164     Note that Qt 4 in general uses the QScrollArea::widget() function
       
  3165     where Qt 3 used QScrollView::viewport(). The rationale for this is
       
  3166     that it is no longer possible to draw directly on a scroll
       
  3167     area. The QScrollArea::widget() function returns the widget set on
       
  3168     the scroll area.
       
  3169 
       
  3170     \c QScrollView was designed to work around the 16-bit limitation
       
  3171     on widget coordinates found on most window systems. In Qt 4, this
       
  3172     is done transparently for \e all widgets, so there is no longer a
       
  3173     need for such functionality in \c QScrollView. For that reason,
       
  3174     the new QAbstractScrollArea and QScrollArea classes are much more
       
  3175     lightweight, and concentrate on handling scroll bars.
       
  3176 
       
  3177     \section1 QServerSocket
       
  3178 
       
  3179     The \c QServerSocket class has been renamed Q3ServerSocket and
       
  3180     moved to the Qt3Support library. In Qt 4, it has been
       
  3181     replaced by QTcpServer.
       
  3182 
       
  3183     With Q3ServerSocket, connections are accepted by reimplementing a
       
  3184     virtual function (Q3ServerSocket::newConnection()). With
       
  3185     QTcpServer, on the other hand, you don't need to subclass.
       
  3186     Instead, simply connect to the QTcpServer::newConnection()
       
  3187     signal.
       
  3188 
       
  3189     \section1 QSettings
       
  3190 
       
  3191     The QSettings class has been rewritten to be more robust and to
       
  3192     respect existing standards (e.g., the INI file format). The API
       
  3193     has also been extensively revised. The old API is still provided
       
  3194     when Qt 3 support is enabled.
       
  3195 
       
  3196     Since the format and location of settings have changed between Qt
       
  3197     3 and Qt 4, the Qt 4 version of your application won't recognize
       
  3198     settings written using Qt 3.
       
  3199 
       
  3200     \section1 QShared
       
  3201 
       
  3202     The \c QShared class has been obsoleted by the more powerful
       
  3203     QSharedData and QSharedDataPointer as a means of creating custom
       
  3204     implicitly shared classes. It has been renamed Q3Shared moved to
       
  3205     the Qt3Support library.
       
  3206 
       
  3207     An easy way of porting to Qt 4 is to include this class into your
       
  3208     project and to use it instead of \c QShared:
       
  3209 
       
  3210     \snippet doc/src/snippets/code/doc_src_porting4.qdoc 63
       
  3211 
       
  3212     If possible, we recommend that you use QSharedData and
       
  3213     QSharedDataPointer instead. They provide thread-safe reference
       
  3214     counting and handle all the reference counting behind the scenes,
       
  3215     eliminating the risks of forgetting to increment or decrement the
       
  3216     reference count.
       
  3217 
       
  3218     \section1 QSignal
       
  3219 
       
  3220     The QSignal class has been renamed to Q3Signal and moved to the
       
  3221     Qt3Support library. The preferred approach is to create your own
       
  3222     QObject subclass with a signal that has the desired signature.
       
  3223     Alternatively, you can call QMetaObject::invokeMethod() if you
       
  3224     want to invoke a slot.
       
  3225 
       
  3226     \section1 QSimpleRichText
       
  3227 
       
  3228     QSimpleRichText has been obsoleted by QTextDocument. It has
       
  3229     bene renamed Q3SimpleRichText and moved to the Qt3Support
       
  3230     library.
       
  3231 
       
  3232     Previously, you would do the following with Q3SimpleRichText:
       
  3233 
       
  3234     \snippet doc/src/snippets/code/doc_src_porting4.qdoc 63a
       
  3235 
       
  3236     However, with QTextDocument, you use the following code instead:
       
  3237 
       
  3238     \snippet doc/src/snippets/code/doc_src_porting4.qdoc 63b
       
  3239 
       
  3240     See \l{Rich Text Processing} for an overview of the Qt 4 rich
       
  3241     text classes.
       
  3242 
       
  3243     \section1 QSlider
       
  3244 
       
  3245     The QSlider::sliderStart() and QSlider::sliderRect() functions
       
  3246     have been removed.
       
  3247 
       
  3248     The slider's rect can now be retrieved using the code snippet below:
       
  3249 
       
  3250     \snippet doc/src/snippets/code/doc_src_porting4.qdoc 63c
       
  3251 
       
  3252     In addition, the direction of a vertical QSlider has changed,
       
  3253     i.e. the bottom is now the minimum, and the top the maximum. You
       
  3254     can use the QAbstractSlider::invertedAppearance property to
       
  3255     control this behavior.
       
  3256 
       
  3257     See \l{#properties}{Properties} for a list of QSlider properties
       
  3258     in Qt 3 that have changed in Qt 4.
       
  3259 
       
  3260     \section1 QSocket
       
  3261 
       
  3262     The \c QSocket class has been renamed Q3Socket and moved to the
       
  3263     Qt3Support library. In Qt 4, it has been replaced by
       
  3264     the QTcpSocket class, which inherits most of its functionality
       
  3265     from QAbstractSocket.
       
  3266 
       
  3267     \section1 QSocketDevice
       
  3268 
       
  3269     The \c QSocketDevice class has been renamed Q3SocketDevice and
       
  3270     moved to the Qt3Support library. In Qt 4, there is no
       
  3271     direct equivalent to Q3SocketDevice:
       
  3272 
       
  3273     \list \o If you use Q3SocketDevice in a thread to perform blocking
       
  3274     network I/O (a technique encouraged by the \e{Qt Quarterly}
       
  3275     article \l{http://qt.nokia.com/doc/qq/qq09-networkthread.html}
       
  3276     {Unblocking Networking}), you can now use QTcpSocket, QFtp, or
       
  3277     QNetworkAccessManager, which can be used from non-GUI threads.
       
  3278 
       
  3279     \o If you use Q3SocketDevice for UDP, you can now use QUdpSocket instead.
       
  3280 
       
  3281     \o If you use Q3SocketDevice for other uses, Qt 4 offers no
       
  3282     alternative right now. However, there is a \c QAbstractSocketEngine
       
  3283     internal class that offers a low-level socket API similar to
       
  3284     Q3SocketDevice. Should the need for such functionality arise in
       
  3285     Qt 4 applications, we will consider making this class public in a
       
  3286     future release.
       
  3287     \endlist
       
  3288 
       
  3289     \section1 QSortedList
       
  3290 
       
  3291     The QSortedList<T> class has been deprecated since Qt 3.0. In Qt
       
  3292     4, it has been moved to the Qt3Support library.
       
  3293 
       
  3294     In new code, we recommend that you use QList<T> instead and use
       
  3295     \l qSort() to sort the items.
       
  3296 
       
  3297     \section1 QSplitter
       
  3298 
       
  3299     The function setResizeMode() has been moved into Qt3Support. Set
       
  3300     the stretch factor in the widget's size policy to get equivalent
       
  3301     functionality.
       
  3302 
       
  3303     The obsolete function drawSplitter() has been removed. Use
       
  3304     QStyle::drawPrimitive() to acheive similar functionality.
       
  3305 
       
  3306     \section1 QSpinBox
       
  3307 
       
  3308     See \l{#properties}{Properties} for a list of QSpinBox properties
       
  3309     in Qt 3 that have changed in Qt 4.
       
  3310 
       
  3311     \section1 QSqlCursor
       
  3312 
       
  3313     The \c QSqlCursor class has been renamed Q3SqlCursor and moved to
       
  3314     the Qt3Support library. In Qt 4, you can use
       
  3315     QSqlQuery, QSqlQueryModel, or QSqlTableModel, depending on
       
  3316     whether you want a low-level or a high-level interface for
       
  3317     accessing databases.
       
  3318 
       
  3319     See \l{QtSql Module} for an overview of the new SQL classes.
       
  3320 
       
  3321     \section1 QSqlDatabase
       
  3322 
       
  3323     QSqlDatabase is now a smart pointer that is passed around by
       
  3324     value. Simply replace all QSqlDatabase pointers by QSqlDatabase
       
  3325     objects.
       
  3326 
       
  3327     \section1 QSqlEditorFactory
       
  3328 
       
  3329     The \c QSqlEditorFactory class has been renamed
       
  3330     Q3SqlEditorFactory and moved to Qt3Support.
       
  3331 
       
  3332     See \l{QtSql Module} for an overview of the new SQL classes.
       
  3333 
       
  3334     \section1 QSqlError
       
  3335 
       
  3336     The enum \c{Type} was renamed to \c{ErrorType}, The values were renamed as well:
       
  3337 
       
  3338     \list
       
  3339     \o None - use NoError instead
       
  3340     \o Connection - use ConnectionError instead
       
  3341     \o Statement - use StatementError instead
       
  3342     \o Transaction - use TransactionError instead
       
  3343     \o Unknown - use UnknownError instead
       
  3344     \endlist
       
  3345 
       
  3346     \section1 QSqlFieldInfo
       
  3347 
       
  3348     The QSqlFieldInfo class has been moved to Qt3Support. Its
       
  3349     functionality is now provided by the QSqlField class.
       
  3350 
       
  3351     See \l{QtSql Module} for an overview of the new SQL classes.
       
  3352 
       
  3353     \section1 QSqlForm
       
  3354 
       
  3355     The \c QSqlForm class has been renamed Q3SqlForm and moved to the
       
  3356     Qt3Support library.
       
  3357 
       
  3358     See \l{QtSql Module} for an overview of the new SQL classes.
       
  3359 
       
  3360     \section1 QSqlPropertyMap
       
  3361 
       
  3362     The \c QSqlPropertyMap class has been renamed Q3SqlPropertyMap
       
  3363     moved to the Qt3Support library.
       
  3364 
       
  3365     See \l{QtSql Module} for an overview of the new SQL classes.
       
  3366 
       
  3367     \section1 QSqlQuery
       
  3368 
       
  3369     QSqlQuery::prev() was renamed to QSqlQuery::previous().
       
  3370     QSqlQuery::prev() remains, but it just calls previous().
       
  3371     QSqlQuery no longer has any virtual methods, i.e., exec(),
       
  3372     value(), seek(), next(), prev(), first(), last(), and the
       
  3373     destructor are no longer virtual.
       
  3374 
       
  3375     \section1 QSqlRecord
       
  3376 
       
  3377     QSqlRecord behaves like a vector now, QSqlRecord::insert() will
       
  3378     actually insert a new field instead of replacing the existing
       
  3379     one.
       
  3380 
       
  3381     \section1 QSqlRecordInfo
       
  3382 
       
  3383     The QSqlRecordInfo class has been moved to Qt3Support. Its
       
  3384     functionality is now provided by the QSqlRecord class.
       
  3385 
       
  3386     See \l{QtSql Module} for an overview of the new SQL classes.
       
  3387 
       
  3388     \section1 QSqlSelectCursor
       
  3389 
       
  3390     The \c QSqlSelectCursor class has been renamed Q3SqlSelectCursor
       
  3391     and moved to the Qt3Support library.
       
  3392 
       
  3393     See \l{QtSql Module} for an overview of the new SQL classes.
       
  3394 
       
  3395     \section1 QStoredDrag
       
  3396 
       
  3397     The \c QStoredDrag class has been renamed Q3StoredDrag and moved
       
  3398     to the Qt3Support library. In Qt 4, use QMimeData
       
  3399     instead and call QMimeData::setData() to set the data.
       
  3400 
       
  3401     See \l{Porting to Qt 4 - Drag and Drop} for a comparison between
       
  3402     the drag and drop APIs in Qt 3 and Qt 4.
       
  3403 
       
  3404     \section1 QStr(I)List
       
  3405 
       
  3406     The QStrList and QStrIList convenience classes have been
       
  3407     deprecated since Qt 2.0. In Qt 4, they have been moved to the
       
  3408     Qt3Support library. If you used any of these, we
       
  3409     recommend that you use QStringList or QList<QByteArray> instead.
       
  3410 
       
  3411     \section1 QStr(I)Vec
       
  3412 
       
  3413     The QStrVec and QStrIVec convenience classes have been deprecated
       
  3414     since Qt 2.0. In Qt 4, they have been moved to Qt3Support. If you
       
  3415     used any of these, we recommend that you use QStringList or
       
  3416     QList<QByteArray> instead.
       
  3417 
       
  3418     \section1 QString
       
  3419 
       
  3420     Here are the main issues to be aware of when porting QString to
       
  3421     Qt 4:
       
  3422 
       
  3423     \list 1
       
  3424     \o  The QString::QString(QChar) constructor performed implicit
       
  3425         conversion in Qt 3. Now, you will need a cast to convert a
       
  3426         QChar to a QString.
       
  3427 
       
  3428     \o  The QString::QString(const QByteArray &) constructor used to
       
  3429         stop at the first '\\0' it encountered, for compatibility
       
  3430         with Qt 1. This quirk has now been fixed; in Qt 4, the
       
  3431         resulting QString always has the same length as the
       
  3432         QByteArray that was passed to the constructor.
       
  3433 
       
  3434     \o  The QString::null static constant has been deprecated in Qt
       
  3435         4. For compatibility, Qt 4 provides a QString::null symbol
       
  3436         that behaves more or less the same as the old constant. The
       
  3437         new idiom is to write QString() instead of QString::null, or
       
  3438         to call clear().
       
  3439 
       
  3440         \oldcode
       
  3441             str1 = QString::null;
       
  3442             if (str2 == QString::null)
       
  3443                 do_something(QString::null);
       
  3444         \newcode
       
  3445             str1.clear();
       
  3446             if (str2.isNull())
       
  3447                 do_something(QString());
       
  3448         \endcode
       
  3449 
       
  3450         In new code, we recommend that you don't rely on the
       
  3451         distinction between a null string and a (non-null) empty
       
  3452         string. See \l{Distinction Between Null and Empty Strings}
       
  3453         for details.
       
  3454 
       
  3455     \o  QString::latin1() and QString::ascii() have been replaced
       
  3456         with QString::toLatin1() and QString::toAscii(), which return
       
  3457         a QByteArray instead of a (non-reentrant) \c{const char *}.
       
  3458         For consistency, QString::utf8() and QString::local8Bit(),
       
  3459         which already returned a QByteArray (actually a \c QCString),
       
  3460         have been renamed QString::toUtf8() and
       
  3461         QString::toLocal8Bit().
       
  3462 
       
  3463         To obtain a \c{const char *} pointer to ASCII or Latin-1 data,
       
  3464         use QString::toAscii() or QString::toLatin1() to obtain a
       
  3465         QByteArray containing the data, then call QByteArray::constData()
       
  3466         to access the character data directly. Note that the pointer
       
  3467         returned by this function is only valid for the lifetime of the
       
  3468         byte array; you should avoid taking a pointer to the data
       
  3469         contained in temporary objects.
       
  3470 
       
  3471         \snippet doc/src/snippets/code/doc_src_porting4.qdoc 64
       
  3472 
       
  3473         In the above example, the \c goodData pointer is valid for the lifetime
       
  3474         of the \c asciiData byte array. If you need to keep a copy of the data
       
  3475         in a non-Qt data structure, use standard C memory allocation and string
       
  3476         copying functions to do so \e before destroying the byte array.
       
  3477 
       
  3478     \o  QString::at() returned a non-const reference, whereas the
       
  3479         new QString::at() returns a const value. Code like
       
  3480 
       
  3481         \snippet doc/src/snippets/code/doc_src_porting4.qdoc 65
       
  3482 
       
  3483         will no longer compile. Instead, use QString::operator[]:
       
  3484 
       
  3485         \snippet doc/src/snippets/code/doc_src_porting4.qdoc 66
       
  3486 
       
  3487     \o  The QString::contains(\e x) function (where \e x is a
       
  3488         character or a string) has been renamed QString::count(\e x).
       
  3489         In addition, there now exists a set of QString::contains()
       
  3490         functions that returns a boolean value. Replace old calls to
       
  3491         contains() with either count() or contains(), depending on
       
  3492         whether you care about the specific number of occurrences of
       
  3493         a character in the string or only care about whether the
       
  3494         string contains that character or not.
       
  3495 
       
  3496     \o  Many functions in QString had a \c bool parameter that
       
  3497         specified case sensitivity. In Qt 4, in the interest of code
       
  3498         readability and maintainability, the \c bool parameters have
       
  3499         been replaced by the Qt::CaseSensitivity enum, which can take
       
  3500         the values Qt::CaseSensitive and Qt::CaseInsensitive.
       
  3501 
       
  3502         \oldcode
       
  3503             if (url.startsWith("http:", false))
       
  3504                 ...
       
  3505         \newcode
       
  3506             if (url.startsWith("http:", Qt::CaseInsensitive))
       
  3507                 ...
       
  3508         \endcode
       
  3509 
       
  3510     \o  The QString::setExpand(uint, QChar) function, which already
       
  3511         was obsolete in Qt 3, is no longer available. Use
       
  3512         QString::operator[] instead.
       
  3513 
       
  3514         \oldcode
       
  3515             str.setExpand(32, '$');
       
  3516         \newcode
       
  3517             str[32] = '$';
       
  3518         \endcode
       
  3519 
       
  3520     \o  The \c QT_NO_ASCII_CAST and \c QT_NO_CAST_ASCII macros have
       
  3521         been renamed \c QT_NO_CAST_TO_ASCII and \c
       
  3522         QT_NO_CAST_FROM_ASCII, respectively.
       
  3523 
       
  3524     \o  The QString::data() used to return the same as
       
  3525         QString::ascii(). It now returns a pointer to the Unicode
       
  3526         data stored in the QString object. Call QString::ascii() if
       
  3527         you want the old behavior.
       
  3528 
       
  3529     \o  QString::arg() now converts two-digit place markers, allowing
       
  3530         up to 99 place markers to be used in any given string.
       
  3531 
       
  3532     \o  Comparisons between QStrings and \c NULL in order to determine
       
  3533         whether strings are empty are no longer allowed.
       
  3534         Use \l{QString::}{isEmpty()} instead.
       
  3535 
       
  3536     \endlist
       
  3537 
       
  3538     \section1 QStringList
       
  3539 
       
  3540     QStringList now inherits from QList<QString> and can no longer be
       
  3541     converted to a QValueList<QString>. Since QValueList inherits QList a
       
  3542     cast will work as expected.
       
  3543 
       
  3544     This change implies some API incompatibilities for QStringList.
       
  3545     For example, at() returns the string, not an iterator. See the
       
  3546     \l{#qvaluelist.section}{section on QValueList} for details.
       
  3547 
       
  3548     The static QStringList::split() function for splitting strings into
       
  3549     lists of smaller strings has been replaced by QString::split(),
       
  3550     which returns a QStringList.
       
  3551 
       
  3552     \section1 QStyle
       
  3553 
       
  3554     The QStyle API has been overhauled and improved. Most of the information on
       
  3555     why this change was done is described in \l{The Qt 4 Style API}{the QStyle overview}.
       
  3556 
       
  3557     Since QStyle is mostly used internally by Qt's widgets and styles and since
       
  3558     it is not essential to the good functioning of an application, there is no
       
  3559     compatibility path. This means that we have changed many enums and
       
  3560     functions and the qt3to4 porting tool will not change much in your qstyle
       
  3561     code. To ease the pain, we list some of the major changes here.
       
  3562 
       
  3563     QStyleOption has taken on a more central role and is no longer an optional
       
  3564     argument, please see the QStyleOption documentation for more information.
       
  3565 
       
  3566     The QStyle::StyleFlags have been renamed QStyle::StateFlags and are now prefixed State_
       
  3567     instead of Style_, in addition the Style_ButtonDefault flag has moved to
       
  3568     QStyleOptionButton.
       
  3569 
       
  3570     The QStyle::PrimitiveElement enumeration has undergone extensive change.
       
  3571     Some of the enums were moved to QStyle::ControlElement, some were removed
       
  3572     and all were renamed. This renaming is not done by the qt3to4 porting tool,
       
  3573     so you must do it yourself. The table below shows how things look
       
  3574     now.
       
  3575 
       
  3576     \table
       
  3577     \header \o Old name \o New name \o Remark
       
  3578     \row \o \c PE_ButtonCommand             \o QStyle::PE_PanelButtonCommand
       
  3579     \row \o \c PE_ButtonDefault             \o QStyle::PE_FrameDefaultButton
       
  3580     \row \o \c PE_ButtonBevel               \o QStyle::PE_PanelButtonBevel
       
  3581     \row \o \c PE_ButtonTool                \o QStyle::PE_PanelButtonTool
       
  3582     \row \o \c PE_ButtonDropDown            \o QStyle::PE_IndicatorButtonDropDown
       
  3583     \row \o \c PE_FocusRect                 \o QStyle::PE_FrameFocusRect
       
  3584     \row \o \c PE_ArrowUp                   \o QStyle::PE_IndicatorArrowUp
       
  3585     \row \o \c PE_ArrowDown                 \o QStyle::PE_IndicatorArrowDown
       
  3586     \row \o \c PE_ArrowRight                \o QStyle::PE_IndicatorArrowRight
       
  3587     \row \o \c PE_ArrowLeft                 \o QStyle::PE_IndicatorArrowLeft
       
  3588     \row \o \c PE_SpinBoxUp                 \o QStyle::PE_IndicatorSpinUp
       
  3589     \row \o \c PE_SpinBoxDown               \o QStyle::PE_IndicatorSpinDown
       
  3590     \row \o \c PE_SpinBoxPlus               \o QStyle::PE_IndicatorSpinPlus
       
  3591     \row \o \c PE_SpinBoxMinus              \o QStyle::PE_IndicatorSpinMinus
       
  3592     \row \o \c PE_SpinBoxSlider             \o QStyle::CE_SpinBoxSlider \o uses QStyle::drawControl()
       
  3593     \row \o \c PE_Indicator                 \o QStyle::PE_IndicatorCheckBox
       
  3594     \row \o \c PE_IndicatorMask             \o N/A \o use QStyle::styleHint() to retrieve mask
       
  3595     \row \o \c PE_ExclusiveIndicator        \o QStyle::PE_IndicatorRadioButton
       
  3596     \row \o \c PE_ExclusiveIndicatorMask    \o N/A \o use QStyle::styleHint() to retrieve mask
       
  3597     \row \o \c PE_DockWindowHandle          \o QStyle::PE_IndicatorToolBarHandle
       
  3598     \row \o \c PE_DockWindowSeparator       \o QStyle::PE_Q3DockWindowSeparator
       
  3599     \row \o \c PE_DockWindowResizeHandle    \o QStyle::PE_IndicatorDockWindowResizeHandle
       
  3600     \row \o \c PE_DockWindowTitle           \o QStyle::CE_DockWindowTitle \o uses QStyle::drawControl()
       
  3601     \row \o \c PE_Splitter                  \o QStyle::CE_Splitter \o uses QStyle::drawControl()
       
  3602     \row \o \c PE_Panel                     \o QStyle::PE_Frame
       
  3603     \row \o \c PE_PanelMenu                 \o QStyle::PE_FrameMenu
       
  3604     \row \o \c PE_PanelMenuBar              \o QStyle::PE_PanelMenuBar
       
  3605     \row \o \c PE_PanelDockWindow           \o QStyle::PE_FrameDockWindow
       
  3606     \row \o \c PE_TabBarBase                \o QStyle::PE_FrameTabBarBase
       
  3607     \row \o \c PE_HeaderSection             \o QStyle::CE_HeaderSection \o uses QStyle::drawControl()
       
  3608     \row \o \c PE_HeaderArrow               \o QStyle::PE_IndicatorHeaderArrow
       
  3609     \row \o \c PE_StatusBarSection          \o QStyle::PE_FrameStatusBar
       
  3610     \row \o \c PE_Separator                 \o QStyle::PE_Q3Separator
       
  3611     \row \o \c PE_SizeGrip                  \o QStyle::CE_SizeGrip \o uses QStyle::drawControl()
       
  3612     \row \o \c PE_CheckMark                 \o QStyle::PE_IndicatorMenuCheckMark
       
  3613     \row \o \c PE_ScrollBarAddLine          \o QStyle::CE_ScrollBarAddLine \o uses QStyle::drawControl()
       
  3614     \row \o \c PE_ScrollBarSubLine          \o QStyle::CE_ScrollBarSubLine \o uses QStyle::drawControl()
       
  3615     \row \o \c PE_ScrollBarAddPage          \o QStyle::CE_ScrollBarAddPage \o uses QStyle::drawControl()
       
  3616     \row \o \c PE_ScrollBarSubPage          \o QStyle::CE_ScrollBarSubPage \o uses QStyle::drawControl()
       
  3617     \row \o \c PE_ScrollBarSlider           \o QStyle::CE_ScrollBarSlider  \o uses QStyle::drawControl()
       
  3618     \row \o \c PE_ScrollBarFirst            \o QStyle::CE_ScrollBarFirst   \o uses QStyle::drawControl()
       
  3619     \row \o \c PE_ScrollBarLast             \o QStyle::CE_ScrollBarLast    \o uses QStyle::drawControl()
       
  3620     \row \o \c PE_ProgressBarChunk          \o QStyle::PE_IndicatorProgressChunk
       
  3621     \row \o \c PE_PanelLineEdit             \o QStyle::PE_FrameLineEdit
       
  3622     \row \o \c PE_PanelTabWidget            \o QStyle::PE_FrameTabWidget
       
  3623     \row \o \c PE_WindowFrame               \o QStyle::PE_FrameWindow
       
  3624     \row \o \c PE_CheckListController       \o QStyle::PE_Q3CheckListController
       
  3625     \row \o \c PE_CheckListIndicator        \o QStyle::PE_Q3CheckListIndicator
       
  3626     \row \o \c PE_CheckListExclusiveIndicato\o QStyle::PE_Q3CheckListExclusiveIndicator
       
  3627     \row \o \c PE_PanelGroupBox             \o QStyle::PE_FrameGroupBox
       
  3628     \row \o \c PE_TreeBranch                \o QStyle::PE_IndicatorBranch
       
  3629     \row \o \c PE_RubberBand                \o QStyle::CE_RubberBand \o uses QStyle::drawControl()
       
  3630     \row \o \c PE_PanelToolBar              \o QStyle::PE_PanelToolBar
       
  3631     \row \o \c PE_ToolBarHandle             \o QStyle::PE_IndicatorToolBarHandle
       
  3632     \row \o \c PE_ToolBarSeparator          \o QStyle::PE_IndicatorToolBarSeparator
       
  3633     \endtable
       
  3634 
       
  3635     The QStyle::drawControlMask() and QStyle::drawComplexControlMask()
       
  3636     functions have been removed. They are replaced with a style hint.
       
  3637 
       
  3638     The QStyle::drawItem() overloads that took both a pixmap and a string have
       
  3639     been removed. Use QStyle::drawItemText() and QStyle::drawItemPixmap() directly.
       
  3640 
       
  3641     The QStyle::itemRect() overload that took both a pixmap and a string is also removed, use
       
  3642     either QStyle::itemTextRect() or QStyle::itemPixmapRect() instead.
       
  3643 
       
  3644     \section1 QStyleSheet
       
  3645 
       
  3646     The QStyleSheet and QStyleSheetItem classes have been renamed
       
  3647     Q3StyleSheet and Q3StyleSheetItem, and have been moved to the
       
  3648     Qt3Support library.
       
  3649 
       
  3650     See \l{Rich Text Processing} for an overview of the Qt 4 rich
       
  3651     text classes, and \l{Qt Style Sheets} for a description of
       
  3652     CSS-like style sheet support in Qt 4.2 and above.
       
  3653 
       
  3654     \section1 QSyntaxHighlighter
       
  3655 
       
  3656     The \c QSyntaxHighlighter class from Qt 3 has been renamed
       
  3657     Q3SyntaxHighlighter and moved to the Qt3Support library. Since Qt
       
  3658     4.1, it has been replaced by a new QSyntaxHighlighter class based
       
  3659     on Qt 4's new rich text engine.
       
  3660 
       
  3661     \section1 QTabBar
       
  3662 
       
  3663     See \l{#properties}{Properties} for a list of QTabBar properties
       
  3664     in Qt 3 that have changed in Qt 4.
       
  3665 
       
  3666     \section1 QTabDialog
       
  3667 
       
  3668     The \c QTabDialog class is no longer part of the public Qt API.
       
  3669     It has been renamed Q3TabDialog and moved to Qt3Support. In Qt 4
       
  3670     applications, you can easily obtain the same result by combining
       
  3671     a QTabWidget with a QDialog and provide \l{QPushButton}s
       
  3672     yourself.
       
  3673 
       
  3674     See also the \l{dialogs/tabdialog} example, which shows how to
       
  3675     implement tab dialogs in Qt 4.
       
  3676 
       
  3677     \section1 QTabWidget
       
  3678 
       
  3679     See \l{#properties}{Properties} for a list of QTabWidget
       
  3680     properties in Qt 3 that have changed in Qt 4.
       
  3681 
       
  3682     \section1 QTable
       
  3683 
       
  3684     The \c QTable, \c QTableItem, \c QComboTableItem, \c
       
  3685     QCheckTableItem, and \c QTableSelection classes have been renamed
       
  3686     Q3Table, Q3TableItem, Q3ComboTableItem, Q3CheckTableItem, and
       
  3687     Q3TableSelection and moved to the Qt3Support library.
       
  3688     New Qt applications should use the new QTableWidget or QTableView
       
  3689     class instead.
       
  3690 
       
  3691     Some of these classes behave differently with respect to the way
       
  3692     they handle \c NULL pointers. For example, Q3TableItem::setPixmap()
       
  3693     no longer accepts \c NULL or 0 to indicate that the item should
       
  3694     contain a null pixmap; in this case, a null pixmap should be
       
  3695     constructed and passed explicitly to the function.
       
  3696 
       
  3697     See \l{Model/View Programming} for an overview of the new item
       
  3698     view classes.
       
  3699 
       
  3700     \section1 QTextCodec
       
  3701 
       
  3702     The loadCharmap() and loadCharmapFromFile() functions are no longer
       
  3703     available in Qt 4. You need to create your own codec if you want to
       
  3704     create a codec based on a POSIX2 charmap definition.
       
  3705 
       
  3706     \section1 QTextDrag
       
  3707 
       
  3708     The \c QTextDrag class has been renamed Q3TextDrag and moved to
       
  3709     the Qt3Support library. In Qt 4, use QMimeData
       
  3710     instead and call QMimeData::setText() to set the data.
       
  3711 
       
  3712     See \l{Porting to Qt 4 - Drag and Drop} for a comparison between
       
  3713     the drag and drop APIs in Qt 3 and Qt 4.
       
  3714 
       
  3715     \section1 QTextEdit
       
  3716 
       
  3717     The old QTextEdit and QTextBrowser classes have been renamed
       
  3718     Q3TextEdit and Q3TextBrowser, and have been moved to Qt3Support.
       
  3719     The new QTextEdit and QTextBrowser have a somewhat different API.
       
  3720 
       
  3721     The \c QTextEdit::setWrapPolicy() function has been renamed to \l{QTextEdit::setWordWrapMode()}{setWordWrapMode()} and the
       
  3722     \c QTextEdit::setWrapColumnOrWidth() function has been renamed to \l{QTextEdit::setLineWrapColumnOrWidth()}
       
  3723     {setLineWrapColumnOrWidth()}. The Q3TextEdit::setWrapPolicy() and Q3TextEdit::setWrapColumnOrWidth() still provide this
       
  3724     functionality in the Q3TextEdit class.
       
  3725 
       
  3726 
       
  3727     See \l{Rich Text Processing} for an overview of the Qt 4 rich
       
  3728     text classes.
       
  3729 
       
  3730     \section1 QTextIStream
       
  3731 
       
  3732     The QTextIStream convenience class is no longer provided in Qt 4. Use
       
  3733     QTextStream directly instead.
       
  3734 
       
  3735     \section1 QTextOStream
       
  3736 
       
  3737     The QTextOStream convenience class is no longer provided in Qt 4. Use
       
  3738     QTextStream directly instead.
       
  3739 
       
  3740     \section1 QTextOStreamIterator
       
  3741 
       
  3742     The undocumented \c QTextOStreamIterator class has been removed
       
  3743     from the Qt library. If you need it in your application, feel
       
  3744     free to copy the source code from the Qt 3 \c <qtl.h> header
       
  3745     file.
       
  3746 
       
  3747     \section1 QTextStream
       
  3748 
       
  3749     QTextStream has undergone a number of API and implementation enhancements,
       
  3750     and some of the changes affect QTextStream's behavior:
       
  3751 
       
  3752     \list
       
  3753     \o QTextStream now uses buffered writing, which means that you need to
       
  3754        call QTextStream::flush(), or use the streaming manipulators \c endl or
       
  3755        \c flush if you need QTextStream to flush its write buffer. The stream is
       
  3756        flushed automatically if QTextStream is deleted or when the device is
       
  3757        closed.
       
  3758     \o QTextStream now uses buffered reading, so if you read a line from the
       
  3759        stream, QTextStream will read as much as it can from the device to
       
  3760        fill up its internal read buffer. This speeds up reading significantly,
       
  3761        but Qt 3 code that mixed QTextStream access and direct device access
       
  3762        may need to be updated.
       
  3763     \o While QTextStream in Qt 3 always translated end-of-line characters from
       
  3764        Windows style ("\\r\\n") to Unix style ("\\n") on Windows, QTextStream in
       
  3765        Qt 4 only does this on devices opened with the \c{QIODevice::Text} mode
       
  3766        (formerly \c{IO_Translate}).
       
  3767     \endlist
       
  3768 
       
  3769     Note that when using a QTextStream on a QFile in Qt 4, calling
       
  3770     QIODevice::reset() on the QFile will not have the expected result
       
  3771     because QTextStream now buffers the file. Use the
       
  3772     QTextStream::seek() function instead.
       
  3773 
       
  3774     \section1 QTextView
       
  3775 
       
  3776     The \c QTextView class has been renamed Q3TextView and moved to the
       
  3777     Qt3Support library.
       
  3778 
       
  3779     \section1 QTimeEdit
       
  3780 
       
  3781     The QTimeEdit class in Qt 4 is a convenience class based on
       
  3782     QDateTimeEdit. The old class has been renamed Q3TimeEdit and moved
       
  3783     to the Qt3Support library.
       
  3784 
       
  3785     See \l{Porting to Qt 4 - Virtual Functions}{Virtual Functions} for
       
  3786     a list of \c QTimeEdit virtual member functions in Qt 3 that are no
       
  3787     longer virtual in Qt 4.
       
  3788 
       
  3789     \section1 QTimer
       
  3790 
       
  3791     Windows restricts the granularity of timers, but starting with Qt 4,
       
  3792     we emulate a finer time resolution. On Windows XP we use the
       
  3793     multimedia timer API, which gives us 1 millisecond resolution for
       
  3794     QTimer.
       
  3795 
       
  3796     Note that other versions of Windows have a lower timer resolution,
       
  3797     and that code relying on underlying system timer restrictions
       
  3798     encounters no such limitations using Qt 4 (e.g., setting an
       
  3799     interval of 0 millisecond results in Qt occupying all of the
       
  3800     processor time when no GUI events need processing).
       
  3801 
       
  3802     \section1 QToolBar
       
  3803 
       
  3804     The old \c QToolBar class, which worked with the old \c
       
  3805     QMainWindow and \c QDockArea classes and inherited from \c
       
  3806     QDockWindow, has been renamed Q3ToolBar and moved to
       
  3807     Qt3Support. Note that, when using Q3ToolBar, the toolbar's actions
       
  3808     must be \l {Q3Action}s.
       
  3809 
       
  3810     Use the new QToolBar class in new applications.
       
  3811 
       
  3812     \note \l{Q3ToolBar}'s
       
  3813     \l{Q3DockWindow::setHorizontallyStretchable()}{horizontallyStretchable}
       
  3814     property can be achieved in QToolBar with
       
  3815     \l{QWidget#Size Hints and Size Policies}{size policies}.
       
  3816 
       
  3817     \section1 QToolButton
       
  3818 
       
  3819     See \l{#properties}{Properties} for a list of QToolButton properties
       
  3820     in Qt 3 that have changed in Qt 4.
       
  3821 
       
  3822     Note that many of the properties that could previously be set in
       
  3823     the constructor must now be set separately.
       
  3824 
       
  3825     \section1 QToolTip
       
  3826 
       
  3827     The QToolTip::setGloballyEnabled() function no longer exists.
       
  3828     Tooltips can be disabled by \l{QObject::installEventFilter()}{installing
       
  3829     an event filter} on qApp (the unique QApplication object) to block events
       
  3830     of type QEvent::ToolTip.
       
  3831 
       
  3832     \section1 QUriDrag
       
  3833 
       
  3834     The \c QUriDrag class has been renamed Q3UriDrag and moved to the
       
  3835     Qt3Support library. In Qt 4, use QMimeData instead
       
  3836     and call QMimeData::setUrl() to set the URL.
       
  3837 
       
  3838     See \l{Porting to Qt 4 - Drag and Drop} for a comparison between
       
  3839     the drag and drop APIs in Qt 3 and Qt 4.
       
  3840 
       
  3841     \section1 QUrl
       
  3842 
       
  3843     The QUrl class has been rewritten from scratch in Qt 4 to be more
       
  3844     standard-compliant. The old QUrl class has been renamed Q3Url and
       
  3845     moved to the Qt3Support library.
       
  3846 
       
  3847     The new QUrl class provides an extensive list of compatibility
       
  3848     functions to ease porting from Q3Url to QUrl. A few functions
       
  3849     require you to change your code:
       
  3850 
       
  3851     \list
       
  3852     \o Q3Url::Q3Url(const Q3Url &, const QString &, bool) can be
       
  3853        simulated by combining the URLs manually (using
       
  3854        QString::operator+(), for example).
       
  3855     \o Q3Url::setEncodedPathAndQuery(const QString &) is replaced by
       
  3856        QUrl::setPath() and QUrl::setEncodedQuery().
       
  3857     \o Q3Url::encodedPathAndQuery() is replaced by QUrl::path() and
       
  3858        QUrl::encodedQuery().
       
  3859     \o Q3Url::isLocalFile() can be simulated by checking that
       
  3860        QUrl::protocol() is "file".
       
  3861     \o Q3Url::toString(bool, bool) is replaced by
       
  3862        QUrl::toString(int), where the \c int parameter specifies a
       
  3863        combination of \l{QUrl::FormattingOptions}{formatting
       
  3864        options}.
       
  3865     \endlist
       
  3866 
       
  3867     \section1 QUrlOperator
       
  3868 
       
  3869     The \c QUrlOperator class is no longer part of the public Qt API.
       
  3870     It has been renamed Q3UrlOperator and moved to Qt3Support.
       
  3871 
       
  3872     From Qt 4.4, the Network Access API provides a subset of the features
       
  3873     provided by \c QUrlOperator that are mostly intended for use with
       
  3874     applications that use the HTTP and FTP protocols. See the
       
  3875     QNetworkRequest, QNetworkReply, and QNetworkAccessManager documentation
       
  3876     for further details.
       
  3877 
       
  3878     \target qvaluelist.section
       
  3879     \section1 QValueList<T>
       
  3880 
       
  3881     The QValueList<T> class has been replaced by QList<T> and
       
  3882     QLinkedList<T> in Qt 4. As a help when porting older Qt
       
  3883     applications, the Qt3Support library contains a
       
  3884     QValueList<T> class implemented in terms of the new
       
  3885     QLinkedList<T>. Similarly, it contains QValueListIterator<T> and
       
  3886     QValueListConstIterator<T> classes implemented in terms of
       
  3887     QLinkedList<T>::iterator and QLinkedList<T>::const_iterator.
       
  3888 
       
  3889     When porting to Qt 4, you have the choice of using QList<T> or
       
  3890     QLinkedList<T> as alternatives to QValueList<T>. QList<T> has an
       
  3891     index-based API and provides very fast random access
       
  3892     (QList::operator[]), whereas QLinkedList<T> has an iterator-based
       
  3893     API.
       
  3894 
       
  3895     Here's a list of problem functions:
       
  3896 
       
  3897     \list
       
  3898     \o  QValueList(const std::list<T> &) doesn't exist in QList or
       
  3899         QLinkedList. You can simulate it by calling
       
  3900         \l{QLinkedList::append()}{append()} in a loop.
       
  3901 
       
  3902     \o  QValueList::insert(iterator, size_type, const T& x) doesn't
       
  3903         exist in QList or QLinkedList. Call
       
  3904         \l{QLinkedList::insert()}{insert()} repeatedly instead.
       
  3905 
       
  3906     \o  QValueList::fromLast() doesn't exist in QList or QLinkedList. Use
       
  3907         QValueList::end() instead.
       
  3908 
       
  3909         \oldcode
       
  3910         for (QValueList<T>::iterator i = list.fromLast(); i != list.begin(); --i)
       
  3911             do_something(*i);
       
  3912         \newcode
       
  3913         QLinkedList<T>::iterator i = list.end();
       
  3914         while (i != list.begin()) {
       
  3915             --i; // decrement i before using it
       
  3916             do_something(*i);
       
  3917         }
       
  3918         \endcode
       
  3919 
       
  3920     \o  QValueList::append() and QValueList::prepend() return an
       
  3921         iterator to the inserted item. QList's and QLinkedList's
       
  3922         corresponding functions don't, but it's not a problem because
       
  3923         QValueList::prepend() always returns begin() and append()
       
  3924         always returns QValueList::end() - 1.
       
  3925 
       
  3926     \o  QValueList::at(\e i) return an iterator to the item at index
       
  3927         \e i. This corresponds to QList::begin() + \e i.
       
  3928 
       
  3929     \o  QValueList::contains(const T &) corresponds to
       
  3930         QList::count(const T &) and QLinkedList::count(const T &).
       
  3931     \endlist
       
  3932 
       
  3933     \section1 QValueVector<T>
       
  3934 
       
  3935     The QValueVector<T> class has been replaced by QVector<T> in Qt
       
  3936     4. As a help when porting older Qt applications, the Qt3Support
       
  3937     library contains a Q3ValueVector<T> class implemented in terms of
       
  3938     the new QVector<T>.
       
  3939 
       
  3940     When porting from QValueVector<T> to QVector<T>, you might run
       
  3941     into the following incompatibilities:
       
  3942 
       
  3943     \list
       
  3944     \o QValueVector(const std::vector<T> &) doesn't exist in QVector.
       
  3945        You can simulate it by calling QVector::append()} in a loop.
       
  3946     \o QValueVector::resize(int, const T &) doesn't exist in QVector.
       
  3947        If you want the new items to be initialized with a particular
       
  3948        value, use QVector::insert() instead.
       
  3949     \o QValueVector::at() on a non-const vector returns a non-const
       
  3950        reference. This corresponds to QVector::operator[]().
       
  3951     \o Both QValueVector::at() functions have an \e ok parameter of
       
  3952        type \c{bool *} that is set to true if the index is within
       
  3953        bounds. This functionality doesn't exist in QVector; instead,
       
  3954        check the index against QVector::size() yourself.
       
  3955     \endlist
       
  3956 
       
  3957     See \l{Generic Containers} for an overview of the Qt 4 container
       
  3958     classes.
       
  3959 
       
  3960     \section1 QVariant
       
  3961 
       
  3962     Some changes to the rest of the Qt library have
       
  3963     implications on QVariant:
       
  3964 
       
  3965     \list 1
       
  3966     \o The \c QVariant::ColorGroup enum value is defined only
       
  3967        if \c QT3_SUPPORT is defined.
       
  3968     \o The \c QVariant::IconSet enum value has been renamed
       
  3969        QVariant::Icon.
       
  3970     \o The \c QVariant::CString enum value is now a synonym for
       
  3971        QVariant::ByteArray.
       
  3972     \endlist
       
  3973 
       
  3974     Also, the QVariant(bool, int) constructor has been replaced by QVariant(bool).
       
  3975     Old code like QVariant(true, 0) should be replaced with QVariant(true); otherwise,
       
  3976     the QVariant(int, void *) overload might accidentally be triggered.
       
  3977 
       
  3978     Many of QVariant's convenience functions in Qt 3, such as toColor() and
       
  3979     toKeySequence(), have been removed to enable QVariant to be part of the
       
  3980     QtCore module. QVariant is still able to hold values of these types.
       
  3981 
       
  3982     Types which are not supported by any of the QVariant constructors can be
       
  3983     stored as variants with the QVariant::fromValue() function. Types with no
       
  3984     suitable convenience function for unpacking can be retrieved with the
       
  3985     QVariant::value() function or passed directly to classes that implement
       
  3986     the QVariant() operator.
       
  3987 
       
  3988     \table
       
  3989     \header \o Qt 3 function \o Qt 4 function
       
  3990     \input porting/porting4-removedvariantfunctions.qdocinc
       
  3991     \endtable
       
  3992 
       
  3993     See the QVariant::Type enum for a list of types supported by QVariant.
       
  3994 
       
  3995     \section1 QVBox
       
  3996 
       
  3997     The \c QVBox class is now only available as Q3VBox in Qt 4. You
       
  3998     can achieve the same result as \c QVBox by creating a QWidget
       
  3999     with a vertical layout:
       
  4000 
       
  4001     \oldcode
       
  4002     QVBox *vbox = new QVBox;
       
  4003     QPushButton *child1 = new QPushButton(vbox);
       
  4004     QPushButton *child2 = new QPushButton(vbox);
       
  4005     \newcode
       
  4006     QWidget *vbox = new QWidget;
       
  4007     QPushButton *child1 = new QPushButton;
       
  4008     QPushButton *child2 = new QPushButton;
       
  4009 
       
  4010     QVBoxLayout *layout = new QVBoxLayout;
       
  4011     layout->addWidget(child1);
       
  4012     layout->addWidget(child2);
       
  4013     vbox->setLayout(layout);
       
  4014     \endcode
       
  4015 
       
  4016     Note that child widgets are not automatically placed into the widget's
       
  4017     layout; you will need to manually add each widget to the QVBoxLayout.
       
  4018 
       
  4019     \section1 QVGroupBox
       
  4020 
       
  4021     The \c QVGroupBox class has been renamed Q3VGroupBox and moved to
       
  4022     the Qt3Support library.
       
  4023     Qt 4 does not provide a specific replacement class for \c QVGroupBox
       
  4024     since QGroupBox is designed to be a generic container widget. As a
       
  4025     result, you need to supply your own layout for any child widgets.
       
  4026 
       
  4027     See \l{#QGroupBox} for more information about porting code that uses
       
  4028     group boxes.
       
  4029 
       
  4030     \section1 QWhatsThis
       
  4031 
       
  4032     The QWhatsThis class has been redesigned in Qt 4. The old \c
       
  4033     QWhatsThis class is available as Q3WhatsThis in Qt3Support.
       
  4034 
       
  4035     \section1 QWidget
       
  4036 
       
  4037     Widget background painting has been greatly improved, supporting
       
  4038     flicker-free updates and making it possible to have
       
  4039     semi-transparent widgets. This renders the following background
       
  4040     handling functions obsolete:
       
  4041 
       
  4042     \list
       
  4043     \o QWidget::repaint(bool noErase) - the \c noErase boolean parameter is gone
       
  4044     \o QWidget::setBackgroundMode(BackgroundMode m)
       
  4045     \o QWidget::backgroundBrush() const
       
  4046     \o QWidget::setBackgroundPixmap(const QPixmap &pm)
       
  4047     \o QWidget::backgroundPixmap() const
       
  4048     \o QWidget::setBackgroundColor(const QColor &c)
       
  4049     \o QWidget::backgroundColor() const
       
  4050     \o QWidget::foregroundColor() const
       
  4051     \o QWidget::eraseColor() const
       
  4052     \o QWidget::setEraseColor(const QColor &c)
       
  4053     \o QWidget::erasePixmap() const
       
  4054     \o QWidget::setErasePixmap(const QPixmap &p)
       
  4055     \o QWidget::paletteForegroundColor()
       
  4056     \o QWidget::setPaletteForegroundColor(const QColor &c)
       
  4057     \o QWidget::paletteBackgroundColor()
       
  4058     \o QWidget::setPaletteBackgroundColor(const QColor &c)
       
  4059     \o QWidget::paletteBackgroundPixmap() const
       
  4060     \o QWidget::setPaletteBackgroundPixmap(const QPixmap &p)
       
  4061     \o QWidget::erase()
       
  4062     \o QWidget::erase(const QRect &r)
       
  4063     \o QWidget::setBackgroundOrigin( BackgroundOrigin )
       
  4064     \o QWidget::BackgroundOrigin backgroundOrigin() const
       
  4065     \o QWidget::backgroundOffset()
       
  4066     \endlist
       
  4067 
       
  4068     Sample code on how to do obtain similar behavior from Qt 4, previously
       
  4069     handled by some of the above functions can be found in the
       
  4070     \l{http://qt.nokia.com/doc/qwidget-qt3.html}{Qt 3 Support Members for QWidget}
       
  4071     page.
       
  4072 
       
  4073     A widget now receives change events in its QWidget::changeEvent()
       
  4074     handler. This makes the following virtual change handlers obsolete:
       
  4075 
       
  4076     \list
       
  4077     \o QWidget::styleChange - use QEvent::StyleChange
       
  4078     \o QWidget::enabledChange - use QEvent::EnabledChange
       
  4079     \o QWidget::paletteChange - use QEvent::PaletteChange
       
  4080     \o QWidget::fontChange - use QEvent::FontChange
       
  4081     \o QWidget::windowActivationChange - use QEvent::ActivationChange
       
  4082     \o QWidget::languageChange - use QEvent::LanguageChange
       
  4083     \endlist
       
  4084 
       
  4085     The following functions were slots, but are no more:
       
  4086     \list
       
  4087     \o QWidget::clearFocus()
       
  4088     \o QWidget::setMouseTracking()
       
  4089     \o QWidget::stackUnder(QWidget*)
       
  4090     \o QWidget::move(int x, int y)
       
  4091     \o QWidget::move(const QPoint &)
       
  4092     \o QWidget::resize(int w, int h)
       
  4093     \o QWidget::resize(const QSize &)
       
  4094     \o QWidget::setGeometry(int x, int y, int w, int h)
       
  4095     \o QWidget::setGeometry(const QRect &)
       
  4096     \o QWidget::adjustSize()
       
  4097     \o QWidget::update(int x, int y, int w, int h)
       
  4098     \o QWidget::update(const QRect&)
       
  4099     \o QWidget::repaint(bool erase)
       
  4100     \o QWidget::repaint(int x, int y, int w, int h, bool erase)
       
  4101     \o QWidget::repaint(const QRect &, bool erase)
       
  4102     \o QWidget::repaint(const QRegion &, bool erase)
       
  4103     \o QWidget::setCaption(const QString &)
       
  4104     \o QWidget::setIcon(const QPixmap &)
       
  4105     \o QWidget::setIconText(const QString &)
       
  4106     \endlist
       
  4107 
       
  4108     The following functions were incorrectly marked as virtual:
       
  4109 
       
  4110     \list
       
  4111     \o QWidget::close(bool alsoDelete)
       
  4112     \o QWidget::create(WId, bool, bool)
       
  4113     \o QWidget::destroy(bool)
       
  4114     \o QWidget::move(int x, int y)
       
  4115     \o QWidget::reparent(QWidget *parent, WFlags, const QPoint &, bool)
       
  4116     \o QWidget::resize(int w, int h)
       
  4117     \o QWidget::setAcceptDrops(bool on)
       
  4118     \o QWidget::setActiveWindow()
       
  4119     \o QWidget::setAutoMask(bool)
       
  4120     \o QWidget::setBackgroundColor(const QColor &)
       
  4121     \o QWidget::setBackgroundMode(BackgroundMode)
       
  4122     \o QWidget::setBackgroundOrigin(BackgroundOrigin)
       
  4123     \o QWidget::setBackgroundPixmap(const QPixmap &)
       
  4124     \o QWidget::setCaption(const QString &)
       
  4125     \o QWidget::setCursor(const QCursor &)
       
  4126     \o QWidget::setEnabled(bool)
       
  4127     \o QWidget::setEraseColor(const QColor &)
       
  4128     \o QWidget::setErasePixmap(const QPixmap &)
       
  4129     \o QWidget::setFocus()
       
  4130     \o QWidget::setFocusPolicy(FocusPolicy)
       
  4131     \o QWidget::setFocusProxy(QWidget *)
       
  4132     \o QWidget::setFont(const QFont &)
       
  4133     \o QWidget::setGeometry(const QRect &)
       
  4134     \o QWidget::setGeometry(int x, int y, int w, int h)
       
  4135     \o QWidget::setIcon(const QPixmap &)
       
  4136     \o QWidget::setIconText(const QString &)
       
  4137     \o QWidget::setKeyCompression(bool)
       
  4138     \o QWidget::setMask(const QBitmap &)
       
  4139     \o QWidget::setMask(const QRegion &)
       
  4140     \o QWidget::setMaximumSize(int maxw, int maxh)
       
  4141     \o QWidget::setMicroFocusHint(int x, int y, int w, int h, bool, QFont *f)
       
  4142     \o QWidget::setMinimumSize(int minw, int minh)
       
  4143     \o QWidget::setMouseTracking(bool enable)
       
  4144     \o QWidget::setPalette(const QPalette &)
       
  4145     \o QWidget::setPaletteBackgroundColor(const QColor &)
       
  4146     \o QWidget::setPaletteBackgroundPixmap(const QPixmap &)
       
  4147     \o QWidget::setSizeIncrement(int w, int h)
       
  4148     \o QWidget::setSizePolicy(QSizePolicy)
       
  4149     \o QWidget::setUpdatesEnabled(bool enable)
       
  4150     \o QWidget::setWState(uint)
       
  4151     \o QWidget::show()
       
  4152     \o QWidget::showFullScreen()
       
  4153     \o QWidget::showMaximized()
       
  4154     \o QWidget::showMinimized()
       
  4155     \o QWidget::showNormal()
       
  4156     \o QWidget::sizePolicy()
       
  4157     \o QWidget::unsetCursor()
       
  4158     \endlist
       
  4159 
       
  4160     The internal clearWState() function was removed. Use
       
  4161     QWidget::setAttribute() instead.
       
  4162 
       
  4163     setWFlags() was renamed QWidget::setWindowFlags().
       
  4164 
       
  4165     clearWFlags() has no direct replacement. You can use
       
  4166     QWidget::setAttribute() instead. For example,
       
  4167     \c{setAttribute(..., false)} to clear an attribute. More information
       
  4168     is available \l{http://qt.nokia.com/doc/qwidget.html#setAttribute}{here}.
       
  4169 
       
  4170     testWFlags() was renamed to \l{QWidget::testAttribute()}{testAttribute()}.
       
  4171 
       
  4172     See \l{#properties}{Properties} for a list of QWidget properties
       
  4173     in Qt 3 that have changed in Qt 4.
       
  4174 
       
  4175     \section1 QWidgetFactory
       
  4176 
       
  4177     The \c QWidgetFactory class has been replaced by QFormBuilder in Qt 4.
       
  4178 
       
  4179     \section1 QWidgetIntDict
       
  4180 
       
  4181     The QWidgetIntDict class was a synonym for QIntDict<QWidget>. It
       
  4182     is no longer available in Qt 4. If you link against Qt3Support,
       
  4183     you can use Q3IntDict<QWidget> instead; otherwise, see the
       
  4184     \l{#qdict.section}{section on QDict<T>}.
       
  4185 
       
  4186     \target qwidgetlist.section
       
  4187     \section1 QWidgetList
       
  4188 
       
  4189     In Qt 3, the QWidgetList class was a typedef for
       
  4190     QPtrList<QWidget>. In Qt 4, it is a typedef for QList<QWidget *>.
       
  4191     See the \l{#qptrlist.section}{section on QPtrList<T>}.
       
  4192 
       
  4193     \section1 QWidgetPlugin
       
  4194 
       
  4195     The QWidgetPlugin class is no longer available in Qt 4. To create
       
  4196     custom widget plugins, subclass QDesignerCustomWidgetInterface to
       
  4197     provide information about the custom widget, and build a plugin in
       
  4198     the way described in the \l{designer/customwidgetplugin}{Custom
       
  4199     Widget Plugin} example.
       
  4200 
       
  4201     \section1 QWidgetStack
       
  4202 
       
  4203     The QWidgetStack class is no longer part of the Qt public API. It
       
  4204     has been renamed Q3WidgetStack and moved to Qt3Support. In Qt 4
       
  4205     applications, you can use QStackedWidget instead to obtain the
       
  4206     same results.
       
  4207 
       
  4208     \section1 QWizard
       
  4209 
       
  4210     The \c QWizard class was reintroduced in Qt 4.3. See the
       
  4211     \l{Trivial Wizard Example}, \l{License Wizard Example} and
       
  4212     \l{Class Wizard Example} for more details.
       
  4213 
       
  4214     \section1 QWorkspace
       
  4215 
       
  4216     The \c QWorkspace in Qt 4 class requires explicit adding of MDI
       
  4217     windows with QWorkspace::addWindow().
       
  4218 */
       
  4219 
       
  4220 /*!
       
  4221     \page porting4-virtual-functions.html
       
  4222     \title Porting to Qt 4 - Virtual Functions
       
  4223     \contentspage {Porting Guides}{Contents}
       
  4224     \previouspage Porting to Qt 4
       
  4225     \nextpage Porting to Qt 4 - Drag and Drop
       
  4226     \ingroup porting
       
  4227     \brief An overview of changes to virtual functions in Qt 4.
       
  4228 
       
  4229     \section1 Virtual Functions
       
  4230 
       
  4231     Virtual functions that changed their signature in Qt 4:
       
  4232 
       
  4233     \table
       
  4234     \header \o Qt 3 function signature \o Qt 4 function signature
       
  4235     \input porting/porting4-modifiedvirtual.qdocinc
       
  4236     \endtable
       
  4237 
       
  4238     Virtual functions that are not virtual in Qt 4:
       
  4239 
       
  4240     \table
       
  4241     \header \o Qt 3 function \o Comment
       
  4242     \input porting/porting4-removedvirtual.qdocinc
       
  4243     \endtable
       
  4244 */