<tdalign="right"valign="center"><imgsrc="logo32.png"align="right"width="64"height="32"border="0"></td></tr></table><h1align=center>Porting to TQt 3.x</h1>
<p> This document describes porting applications from TQt 2.x to TQt 3.x.
<p> The TQt 3.x series is not binary compatible with the 2.x series. This
means programs compiled for TQt 2.x must be recompiled to work with TQt
3.x. TQt 3.x is also not completely <em>source</em> compatible with 2.x,
however all points of incompatibility cause compiler errors or
run-time messages (rather than mysterious results). TQt 3.x includes
many additional features and discards obsolete functionality. Porting
from TQt 2.x to TQt 3.x is straightforward, and once completed makes
the considerable additional power and flexibility of TQt 3.x available
for use in your applications.
<p> To port code from TQt 2.x to TQt 3.x:
<p><oltype=1>
<p><li> Briefly read the porting notes below to get an idea of what to expect.
<li> Be sure your code compiles and runs well on all your target platforms
with TQt 2.x.
<li> Recompile with TQt 3.x. For each error, search below for related
identifiers (e.g. function names, class names). This document
mentions all relevant identifiers to help you get the information
you need at the cost of being a little verbose.
<li> If you get stuck, ask on the <ahref="http://qt-interest.trolltech.com/">qt-interest</a> mailing list, or Trolltech Technical Support if
you're a registered licensee.
<p></ol>
<p> Table of contents:
<p><!-- toc -->
<ul>
<li><ahref="#1"> Link Errors on Windows
</a>
<li><ahref="#2"> Header file inclusion changes
</a>
<li><ahref="#3"> Namespace
</a>
<li><ahref="#4"> Removed Functions
</a>
<li><ahref="#5"> Obsoleted Functions
</a>
<li><ahref="#6"> Collection Class Renaming
</a>
<li><ahref="#7"> TQButtonGroup
</a>
<li><ahref="#8"> TQDate
</a>
<li><ahref="#9"> TQFileDialog
</a>
<li><ahref="#10"> TQFont
</a>
<li><ahref="#11"> TQInputDialog
</a>
<li><ahref="#12"> TQLayout and Other Abstract Layout Classes
</a>
<li><ahref="#13"> TQListViewItem
</a>
<li><ahref="#14"> TQMoveEvent
</a>
<li><ahref="#15"> TQMultiLineEdit
</a>
<li><ahref="#16"> TQPrinter
</a>
<li><ahref="#17"> TQRegExp
</a>
<ul>
<li><ahref="#17-1"> New special characters
</a>
<li><ahref="#17-2"> TQRegExp::operator=()
</a>
<li><ahref="#17-3"> TQRegExp::match()
</a>
<li><ahref="#17-4"> TQRegExp::find()
</a>
<li><ahref="#17-5"> TQString::findRev() and TQString::contains()
</a>
<li><ahref="#17-6"> TQString::replace()
</a>
</ul>
<li><ahref="#18"> TQSemiModal
</a>
<li><ahref="#19"> TQSortedList
</a>
<li><ahref="#20"> TQTableView
</a>
<li><ahref="#21"> TQToolButton
</a>
<li><ahref="#22"> TQTextStream
</a>
<li><ahref="#23"> TQTranslator
</a>
<li><ahref="#24"> TQWidget
</a>
<li><ahref="#25"> TQXml Classes
</a>
<ul>
<li><ahref="#25-1"> TQXmlInputSource
</a>
<li><ahref="#25-2"> TQXmlLocator
</a>
</ul>
<li><ahref="#26"> Asynchronous I/O Classes
</a>
<li><ahref="#27"> Transparent widgets
</a>
<li><ahref="#28"> Bezier Curves
</a>
<li><ahref="#29"> Locale-aware String Comparisons in TQIconView, TQListBox,
TQListView and TQTable
</a>
</ul>
<!-- endtoc -->
<p><aname="Linkerrors"></a>
<h2> Link Errors on Windows
</h2>
<aname="1"></a><p> On Windows, originally in TQt 2.x, the default configuration of the TQt
library is static. If you just use the default configuration you
don't need to set certain preprocessor defines. In TQt 3.0, the
default configuration of the TQt library is to build it as a shared
library, therefore the preprocessor define <tt>QT_DLL</tt> is needed.
<p> If you use tmake with TQt 2.x, and now use qmake with TQt 3.x, then the
cause of the problem is with the project file. In the project file,
there is usually line that looks like:
<p><tt>CONFIG</tt> = ...
<p> this should be changed to
<p><tt>CONFIG</tt> += ...
<p> so that qmake can look at the configuration that TQt was built with and
set any relevant preprocessor defines in the makefile.
<p><aname="Headers"></a>
<h2> Header file inclusion changes
</h2>
<aname="2"></a><p> TQt 3.x remove some unnecessary nested #include directives from
header files. This speeds up compilation when you don't need those
nested header files. But in some cases you will find you need to add
an extra #include to your files.
<p> For example, if you get a message about <ahref="qstringlist.html">TQStringList</a> or its functions
not being defined, then add <tt>#include <qstringlist.h></tt> at
the top of the file giving the error.
<p> Header files that you might need to add #include directives for include:
<ul>
<li><tt><qcursor.h></tt>
<li><tt><qpainter.h></tt>
<li><tt><qpen.h></tt>
<li><tt><qstringlist.h></tt>
<li><tt><qregexp.h></tt>
<li><tt><qstrlist.h></tt>
<li><tt><qstyle.h></tt>
<li><tt><qvaluelist.h></tt>
</ul>
<p><h2> Namespace
</h2>
<aname="3"></a><p> TQt 3.x is namespace clean. A few global identifiers that had been
left in TQt 2.x have been discarded.
<p> Enumeration <ahref="qt.html#CursorShape-enum">TQt::CursorShape</a> and its values are now part of the
special <ahref="qt.html">TQt</a> class defined in qnamespace.h. If you get compilation
errors about these being missing (unlikely, since most of your code will
be in classes that inherit from the TQt namespace class), then apply
<li><ahref="qcolorgroup.html#TQColorGroup">TQColorGroup::TQColorGroup</a>( const <ahref="qcolor.html">TQColor</a>& foreground, const TQColor & background, const TQColor & light, const TQColor & dark, const TQColor & mid, const TQColor & text, const TQColor & base )
<li><ahref="qfontdatabase.html#font">TQFontDatabase::font</a>( const TQString & familyName, const TQString & style, int pointSize, const TQString & )
<li><ahref="qfontdatabase.html#isBitmapScalable">TQFontDatabase::isBitmapScalable</a>( const TQString & family, const TQString & style, const TQString & ) const
<li><ahref="qfontdatabase.html#isFixedPitch">TQFontDatabase::isFixedPitch</a>( const TQString & family, const TQString & style, const TQString & ) const
<li><ahref="qfontdatabase.html#isScalable">TQFontDatabase::isScalable</a>( const TQString & family, const TQString & style, const TQString & ) const
<li><ahref="qfontdatabase.html#isSmoothlyScalable">TQFontDatabase::isSmoothlyScalable</a>( const TQString & family, const TQString & style, const TQString & ) const
<li><ahref="qfontdatabase.html#italic">TQFontDatabase::italic</a>( const <ahref="qstring.html">TQString</a>& family, const TQString & style, const TQString & ) const
<li><ahref="qfontdatabase.html#pointSizes">TQFontDatabase::pointSizes</a>( const TQString & family, const TQString & style, const TQString & )
<li><ahref="qfontdatabase.html#smoothSizes">TQFontDatabase::smoothSizes</a>( const TQString & family, const TQString & style, const TQString & )
<li><ahref="qfontdatabase.html#styles">TQFontDatabase::styles</a>( const TQString & family, const TQString & ) const
<li><ahref="qfontdatabase.html#weight">TQFontDatabase::weight</a>( const TQString & family, const TQString & style, const TQString & ) const
<li><ahref="qstyle.html#tabbarMetrics">TQStyle::tabbarMetrics</a>( const <ahref="qwidget.html">TQWidget</a> *t, int & hf, int & vf, int & ov ) const
<aname="7"></a><p> In TQt 2.x, the function <ahref="qbuttongroup.html#selected">TQButtonGroup::selected</a>() returns the selected
<em>radio</em> button (<ahref="qradiobutton.html">TQRadioButton</a>). In TQt 3.0, it returns the selected <em>toggle</em> button (<ahref="qbutton.html#toggleButton-prop">TQButton::toggleButton</a>), a more general concept.
This might affect programs that use TQButtonGroups that contain a
mixture of radio buttons and non-radio (e.g. <ahref="qcheckbox.html">TQCheckBox</a>) toggle buttons.
<p><h2><ahref="qdate.html">TQDate</a>
</h2>
<aname="8"></a><p> Two TQDate member functions that were virtual in TQt 2.0 are not virtual
in TQt 3.0. This is only relevant if you subclassed TQDate and
reimplemented these functions:
<p><ul>
<li><ahref="qstring.html">TQString</a><ahref="qdate.html#monthName">TQDate::monthName</a>( int month ) const
<li> TQString <ahref="qdate.html#dayName">TQDate::dayName</a>( int weekday ) const
</ul>
<p> In addition to no longer being virtual, TQDate::monthName() and
TQDate::dayName() have been renamed <ahref="qdate.html#shortMonthName">TQDate::shortMonthName</a>() and
<ahref="qdate.html#shortDayName">TQDate::shortDayName</a>() and have been made static (as they should had
been in the first place). The old names are still provided for source
compatibility.
<p><h2><ahref="qfiledialog.html">TQFileDialog</a>
</h2>
<aname="9"></a><p> If the mode was not set explicitly, and the user entered a
non-existent file, the dialog would accept this. In TQt 3.x, you must
set the mode, e.g. setMode(TQFileDialog::AnyFile), to get the same
behavior.
<p><h2><ahref="qfont.html">TQFont</a>
</h2>
<aname="10"></a><p> The internals of TQFont have changed significantly between TQt 2.2 and
TQt 3.0, to give better Unicode support and to make developing
internationalized applications easier. The original API has been
preserved with minimal changes. The CharSet enum and its related
functions have disappeared. This is because TQt now handles all charset
related issues internally, and removes this burden from the developer.
<p> If you used the CharSet enum or its related functions, e.g
TQFont::charSet() or TQFont::setCharSet(), just remove them from your
code. There are a few functions that took a TQFont::CharSet as a
parameter; in these cases simply remove the charset from the
<p><h2><ahref="qlayout.html">TQLayout</a> and Other Abstract Layout Classes
</h2>
<aname="12"></a><p> The definitions of <ahref="qglayoutiterator.html">TQGLayoutIterator</a>, <ahref="qlayout.html">TQLayout</a>, <ahref="qlayoutitem.html">TQLayoutItem</a>, <ahref="qlayoutiterator.html">TQLayoutIterator</a>, <ahref="qspaceritem.html">TQSpacerItem</a> and <ahref="qwidgetitem.html">TQWidgetItem</a> have been moved from <tt><qabstractlayout.h></tt> to <tt><qlayout.h></tt>. The header <tt><qabstractlayout.h></tt> now includes <tt><qlayout.h></tt> for compatibility. It
still compiles with TQt 3, but produces a different result (the case sensitivity
and wildcard options are forgotten). This way,
<pre>
rx = "beta";
</pre>
is the same as
<pre>
rx = TQRegExp( "beta" );
</pre>
which is what one expects.
<p><h3> TQRegExp::match()
</h3>
<aname="17-3"></a><p> The following function is now obsolete, as it has an unwieldy
parameter list and was poorly named:
<ul>
<li> bool <ahref="qregexp.html#match">TQRegExp::match</a>( const <ahref="qstring.html">TQString</a>& str, int index = 0,
int * len = 0, bool indexIsStart = TRUE ) const
</ul>
It will be removed in a future version of TQt. Its <ahref="qregexp.html#match">documentation</a> explains how to replace it.
<p><h3> TQRegExp::find()
</h3>
<aname="17-4"></a><p> This function was removed, after a brief appearance in TQt 2.2. Its
name clashed with <ahref="qstring.html#find">TQString::find</a>(). Use <ahref="qregexp.html#search">TQRegExp::search</a>() or <ahref="qstring.html#find">TQString::find</a>() instead.
<p><h3><ahref="qstring.html#findRev">TQString::findRev</a>() and <ahref="qstring.html#contains">TQString::contains</a>()
</h3>
<aname="17-5"></a><p><ahref="qstring.html#findRev">TQString::findRev</a>()'s and <ahref="qstring.html#contains">TQString::contains</a>()'s semantics have changed
between 2.0 and 3.0 to be more consistent with the other overloads.
<p> For example,
<pre>
TQString( "" ).contains( TQRegExp("") )
</pre>
returns 1 in TQt 2.0; it returns 0 in TQt 3.0. Also, "^" now really means
With TQt 3.0, the compiler gives an error. The solution is to use a
TQRegExp cast:
<pre>
text.replace( TQRegExp("[A-Z]+"), "" );
</pre>
This change makes it possible to introduce a
TQString::replace(TQString, TQString) overload in a future version of TQt
without breaking source compatibility.
<p><h2> TQSemiModal
</h2>
<aname="18"></a><p> The TQSemiModal class is now obsolete. You should call show() on a
modal dialog instead.
<p><h2> TQSortedList
</h2>
<aname="19"></a><p> The TQSortedList class is now obsolete. Consider using a <ahref="qdict.html">TQDict</a>, a <ahref="qmap.html">TQMap</a>
or a plain <ahref="qptrlist.html">TQPtrList</a> instead.
<p><h2> TQTableView
</h2>
<aname="20"></a><p> The TQTableView class has been obsoleted and is no longer a part of the
TQt API. Either use the powerful <ahref="qtable.html">TQTable</a> class or the simplistic
<ahref="qgridview.html">TQGridView</a> in any new code you create. If you really need the old table
view for compatibility you can find it in <tt>$QTDIR/src/attic/qttableview.{cpp,h}</tt>. Note that the class has been
renamed from TQTableView to TQtTableView to avoid name clashes. To use
it, simply include it in your project and rename TQTableView to
TQtTableView throughout.
<p><h2><ahref="qtoolbutton.html">TQToolButton</a>
</h2>
<aname="21"></a><p> The <ahref="qtoolbutton.html">TQToolButton</a> class used to distinguish between "on" and "off"
icons. In 3.0, this mechanism was moved into the <ahref="qiconset.html">TQIconSet</a> class
(see <ahref="qiconset.html#State-enum">TQIconSet::State</a>).
<p> The old <ahref="qtoolbutton.html#onIconSet-prop">TQToolButton::onIconSet</a> and <ahref="qtoolbutton.html#offIconSet-prop">TQToolButton::offIconSet</a>
properties are still provided so that old source will compile, but
their semantics have changed: they are now synonyms for <ahref="qtoolbutton.html#iconSet-prop">TQToolButton::iconSet</a>. If you used that distinction in TQt 2.x, you will
need to adjust your code to use the <ahref="qiconset.html">TQIconSet</a> On/Off mechanism.
<p> Likewise, the <em>on</em> parameter of these two functions is now ignored:
<p><ul>
<li> void TQToolButton::setIconSet ( const TQIconSet & set, bool on )
<li> TQIconSet TQToolButton::iconSet ( bool on ) const
</ul>
<p> These functions are only provided for ease of porting. New code
should use the following instead:
<p><ul>
<li> void <ahref="qtoolbutton.html#setIconSet">TQToolButton::setIconSet</a>( const TQIconSet & set )
<ahref="qwidget.html#backgroundPixmap">TQWidget::backgroundPixmap</a>() and <ahref="qwidget.html#setBackgroundPixmap">TQWidget::setBackgroundPixmap</a>() have
often been the source of much confusion in previous releases. TQt 3.0
addresses this by obsoleting these functions and by replacing them
with eight new functions: <ahref="qwidget.html#eraseColor">TQWidget::eraseColor</a>(),
<aname="26"></a><p> TQASyncIO, TQDataSink, TQDataSource, TQIODeviceSource and TQDataPump were
used internally in previous versions of TQt, but are not used anymore.
They are now obsolete.
<p><h2> Transparent widgets
</h2>
<aname="27"></a><p> In TQt 2.x, the AutoMask property was used to obtain a
transparent-looking widget. In general, this approach is slow and
processor hungry. TQt 3.0 uses the BackgroundOrigin which provides
vastly improved performance and more flexibility in most cases. The
few classes for which the AutoMask property is still the best approach
are <ahref="qcheckbox.html">TQCheckBox</a>, <ahref="qcombobox.html">TQComboBox</a>, <ahref="qpushbutton.html">TQPushButton</a>, <ahref="qradiobutton.html">TQRadioButton</a> and <ahref="qtabwidget.html">TQTabWidget</a>.
<p><h2> Bezier Curves
</h2>
<aname="28"></a><p> The function names for Bezier curves in <ahref="qpainter.html">TQPainter</a> and <ahref="qpointarray.html">TQPointArray</a> have
been corrected. They now properly reflect their cubic form instead of
a quadratic one. If you have been using either
TQPainter::drawQuadBezier() or TQPointArray::quadBezier() you must
replace these calls with
<ul>
<li> void <ahref="qpainter.html#drawCubicBezier">TQPainter::drawCubicBezier</a>( const TQPointArray &, int index=0 ) and
respectively. Neither the arguments nor the resulting curve have changed.
<p><h2> Locale-aware String Comparisons in <ahref="qiconview.html">TQIconView</a>, <ahref="qlistbox.html">TQListBox</a>,
<ahref="qlistview.html">TQListView</a> and <ahref="qtable.html">TQTable</a>
</h2>
<aname="29"></a><p> In TQt 2.x, <ahref="qstring.html">TQString</a> only provided string comparisons using the Unicode
values of the characters of a string. This is efficient and reliable,
but it is not the appropriate order for most languages. For example,
French users expect 'é' (e acute) to be treated essentially as
'e' and not put after 'z'.
<p> In TQt 3.0, <ahref="qstring.html#localeAwareCompare">TQString::localeAwareCompare</a>() implements locale aware
string comparisions on certain platforms. The classes <ahref="qiconview.html">TQIconView</a>, <ahref="qlistbox.html">TQListBox</a>, <ahref="qlistview.html">TQListView</a> and <ahref="qtable.html">TQTable</a> now use
TQString::localeAwareCompare() instead of <ahref="qstring.html#compare">TQString::compare</a>(). If you
want to control the behaviour yourself you can always reimplement