From ea318d1431c89e647598c510c4245c6571aa5f46 Mon Sep 17 00:00:00 2001 From: Timothy Pearson Date: Thu, 26 Jan 2012 23:32:43 -0600 Subject: Update to latest tqt3 automated conversion --- doc/html/porting2.html | 200 ++++++++++++++++++++++++------------------------- 1 file changed, 100 insertions(+), 100 deletions(-) (limited to 'doc/html/porting2.html') diff --git a/doc/html/porting2.html b/doc/html/porting2.html index 723a4e0a0..0276d068b 100644 --- a/doc/html/porting2.html +++ b/doc/html/porting2.html @@ -107,7 +107,7 @@ that is the TQt Developer Community!
  • TQMultiLineEdit
  • TQPainter
  • TQPicture -
  • TQPoint, TQPointArray, TQSize and TQRect +
  • TQPoint, TQPointArray, TQSize and TQRect
  • TQPixmap
  • TQRgb
  • TQScrollView @@ -127,9 +127,9 @@ that is the TQt Developer Community!

    TQt 2.x is namespace-clean, unlike 1.x. TQt now uses very few global identifiers. Identifiers like red, blue, LeftButton, AlignRight, Key_Up, Key_Down, NoBrush etc. are now part of a -special class TQt (defined in qnamespace.h), +special class TQt (defined in ntqnamespace.h), which is inherited by -most TQt classes. Member functions of classes that inherit from TQWidget, +most TQt classes. Member functions of classes that inherit from TQWidget, etc. are totally unaffected, but code that is not in functions of classes inherited from TQt, you must qualify these identifiers like this: TQt::red, @@ -186,7 +186,7 @@ of your functions accordingly.

  •  TQValidator::fixup(TQString &)
    -
  •  TQSlider::paintSlider(TQPainter *, const TQRect &)
    +
  •  TQSlider::paintSlider(TQPainter *, const TQRect &)

    This is one class of changes that are @@ -202,10 +202,10 @@ function that is not in a subclass of TQListViewIte

    Collection classes

    The collection classes include generic classes such as TQGDict, TQGList, and -the subclasses such as TQDict and TQList. +the subclasses such as TQDict and TQList.

    The macro-based TQt collection classes are obsolete; use the -template-based classes instead. Simply remove includes of qgeneric.h and -replace e.g. Q_DECLARE(TQCache,TQPixmap) with TQCache. +template-based classes instead. Simply remove includes of ntqgeneric.h and +replace e.g. Q_DECLARE(TQCache,TQPixmap) with TQCache.

    The GCI global typedef is replaced by TQCollection::Item. Only if you make your own subclasses of the undocumented generic collection classes will you have GCI in your code. @@ -217,9 +217,9 @@ is not set (i.e. if the QT_NO_CHECK flag is defined).

    The debug() function now outputs nothing if TQt was compiled with the QT_NO_DEBUG macro defined.

    TQString

    -

    TQString has undergone major changes internally, and although it is highly +

    TQString has undergone major changes internally, and although it is highly backward compatible, it is worth studying in detail when porting to TQt 2.x. -The TQt 1.x TQString class has been renamed to TQCString in TQt 2.x, though if +The TQt 1.x TQString class has been renamed to TQCString in TQt 2.x, though if you use that you will incur a performance penalty since all TQt functions that took const char* now take const TQString&.

    @@ -237,7 +237,7 @@ might indicate that the true nature of the data you are dealing with is uncertain. If the data is NUL-terminated 8-bit data, use TQCString; if it is unterminated (ie. contains NULs) 8-bit data, use TQByteArray; if it is text, -use TQString. +use TQString.

  • Put a breakpoint in
     TQString::latin1()
    @@ -268,7 +268,7 @@ and ideally you'll only need latin1() or implicit conversion when interfacing to facilities that do not have Unicode support.

    Automatic-expanding
    -A big advantage of the new TQString is that it automatically expands +A big advantage of the new TQString is that it automatically expands when you write to an indexed position.

    TQChar and TQCharRef
    @@ -282,11 +282,11 @@ has basically the same functionality as a TQChar, except it is more restricted in what you can assign to it and cast it to (to avoid programming errors).

    Use TQString
    -Try to always use TQString. If you must, use TQCString which is the +Try to always use TQString. If you must, use TQCString which is the old implementation from TQt 1.x.

    Unicode vs. ASCII
    -Every conversion to and from ASCII is wasted time, so try to use TQString +Every conversion to and from ASCII is wasted time, so try to use TQString as much as possible rather than const char*. This also ensures you have full 16-bit support.

    Convertion to ASCII
    @@ -309,11 +309,11 @@ use_sub_string( my_string.mid(index) )
    The TQString constructor taking a const char* and an integer is removed. Use of this constructor was error-prone, since the length included the -'\0' terminator. Use TQString::left(int) or TQString::fromLatin1( const char*, +'\0' terminator. Use TQString::left(int) or TQString::fromLatin1( const char*, int ) -- in both cases the int parameter signifies the number of characters.

    TQString(int) is private
    -The TQString constructor taking an integer is now private. This function +The TQString constructor taking an integer is now private. This function is not meaningful anymore, since TQString does all space allocation automatically. 99% of cases can simple be changed to use the default constructor, TQString(). @@ -328,9 +328,9 @@ been made safe - you no longer need to pre-allocate space (though for other reasons, sprintf is still a poor choice - eg. it doesn't pass Unicode). The only remaining common case is conversion of 0 (NULL) to TQString, which would usually give expected results in TQt 1.x. For TQt 2.x the correct -syntax is to use TQString::null, though note that +syntax is to use TQString::null, though note that the default constructor, TQString(), creates a null string too. -Assignment of 0 to a TQString is ambiguous - assign +Assignment of 0 to a TQString is ambiguous - assign TQString::null; you'll mainly find these in code that has been converted from const char* types to TQString. This also prevents a common error case from TQt 1.x - in @@ -356,28 +356,28 @@ summary of how much your application is doing Unicode and ASCII back-and-forth conversions.

    TQString::detach() is obsolete and removed
    -Since TQString is now always shared, this function does nothing. +Since TQString is now always shared, this function does nothing. Remove calls to TQString::detach().

    TQString::resize(int size) is obsolete and removed
    Code using this to truncate a string should use -truncate(size-1). +truncate(size-1). Code using qstr.resize(0) should use qstr = TQString::null. Code calling resize(n) prior to using -operator[] up to n just remove +operator[] up to n just remove the resize(n) completely.

    TQString::size() is obsolete and removed
    Calls to this function must be replaced by -length()+1. +length()+1.

    TQString::setStr(const char*) is removed
    Try to understand why you were using this. If you just meant assignment, use that. Otherwise, you are probably using TQString as an array of bytes, in which case use -TQByteArray or TQCString instead. +TQByteArray or TQCString instead.

    TQString is not an array of bytes
    -Code that uses TQString as an array of bytes should use TQByteArray +Code that uses TQString as an array of bytes should use TQByteArray or a char[], then convert that to a TQString if needed.

    "string = 0"
    @@ -406,26 +406,26 @@ where you would have used 0 with char pointers. This means that inserting a 0-character in the middle of the string does not change the length(). ie.
    -   TQString s = "fred";
    +   TQString s = "fred";
        s[1] = '\0';
    -     // s.length() == 4
    +     // s.length() == 4
          // s == "f\0ed"
    -     // s.latin1() == "f"
    +     // s.latin1() == "f"
        s[1] = 'r';
          // s == "fred"
    -     // s.latin1() == "fred"
    +     // s.latin1() == "fred"
      
    Especially look out for this type of code:
    -   TQString s(2);
    +   TQString s(2);
        s[0] = '?';
        s[1] = 0;
      
    This creates a string 2 characters long. To find these problems while converting, you might like to -add Q_ASSERT(strlen(d->ascii)==d->len) inside +add Q_ASSERT(strlen(d->ascii)==d->len) inside
     TQString::latin1()
    .

    TQString or Standard C++ string?
    @@ -436,10 +436,10 @@ to be so (for the small number of platforms where it is defined at all). This is the same mistake made over and over in the history of C - only when non-8-bit characters are the norm do programmers find them usable. Though it is possible to convert between -string and TQString, it is less efficient than using TQString throughout. +string and TQString, it is less efficient than using TQString throughout. For example, when using:
    -    TQLabel::setText( const TQString& )
    +    TQLabel::setText( const TQString& )
     
    if you use string, like this: @@ -453,13 +453,13 @@ if you use string, like this: that will create a (ASCII only) copy of str, stored in mylabel. But this:
    -    void myclass::dostuffwithtext( const TQString& str )
    +    void myclass::dostuffwithtext( const TQString& str )
         {
             mylabel.setText( str );
         }
     
    -will make an implicitly shared reference to str in the TQLabel - no copying +will make an implicitly shared reference to str in the TQLabel - no copying at all. This function might be 10 nested function calls away from something like this:
    @@ -470,7 +470,7 @@ like this:
     
    At this point, in TQt 2.x, the tr() does a very fast dictionary lookup -through memory-mapped message files, returning some Unicode TQString for +through memory-mapped message files, returning some Unicode TQString for the appropriate language (the default being to just make a TQString out of the text, of course - you're not forced to use any of these features), and that same memory mapped Unicode will be passed @@ -505,7 +505,7 @@ darkMagenta, and darkYellow) are in the TQt namespace. -In members of classes that inherit the TQt namespace-class (eg. TQWidget +In members of classes that inherit the TQt namespace-class (eg. TQWidget subclasses), you can use the unqualified names as before, but in global functions (eg. main()), you need to qualify them: TQt::red, TQt::white, etc. See also the TQRgb section below. @@ -515,13 +515,13 @@ be in the more efficient order (for typical contemporary hardware). If your code made assumptions about the order, you will get blue where you expect red and vice versa (you'll not notice the problem if you use shades of gray, green, or magenta). You should port your code to use the -creator function qRgb(int r,int g,int b) and the -access functions qRed(TQRgb), qBlue(TQRgb), and qGreen(TQRgb). +creator function qRgb(int r,int g,int b) and the +access functions qRed(TQRgb), qBlue(TQRgb), and qGreen(TQRgb). If you are using the alpha channel, it hasn't moved, but you should use -the functions qRgba(int,int,int,int) and qAlpha(TQRgb). Note also that -TQColor::pixel() does not return a TQRgb (it never did on all platforms, +the functions qRgba(int,int,int,int) and qAlpha(TQRgb). Note also that +TQColor::pixel() does not return a TQRgb (it never did on all platforms, but your code may have assumed so on your platform) - this may also produce -strange color results - use TQColor::rgb() if you want a TQRgb. +strange color results - use TQColor::rgb() if you want a TQRgb.

    TQDataStream

    The TQDatastream serialization format of most TQt classes is changed in TQt 2.x. Use

     TQDataStream::setVersion( 1 )
    @@ -532,7 +532,7 @@ compatibility issues:
    • TQString: TQt 1.x has no Unicode support, so strings will be serialized by writing the classic C string returned by
      -        TQString::latin1().
      + TQString::latin1().
    • TQPoint & al.: Coordinates will be truncated to the TQt 1.x 16 bit format. @@ -540,7 +540,7 @@ truncated to the TQt 1.x 16 bit format.

      TQWidget

      TQWidget::recreate()

      -This function is now called reparent(). +This function is now called reparent().

      TQWidget::setAcceptFocus(bool)

      This function is removed. @@ -562,14 +562,14 @@ When processing a paintEvent, painting is only permitted within the update region specified in the event. Any painting outside will be clipped away. This shouldn't break any code (it was always like this on MS-Windows) but makes many explicit calls to -TQPainter::setClipRegion() superfluous. Apart from the improved +TQPainter::setClipRegion() superfluous. Apart from the improved consistency, the change is likely to reduce flicker and to make TQt event slightly faster.

      TQIODevice

      The protected member TQIODevice::index is renamed to TQIODevice::ioIndex to avoid warnings and to allow compilation with bad C libraries that -#define index to strchr. If you have made a subclass of TQIODevice, +#define index to strchr. If you have made a subclass of TQIODevice, check every occurrence of the string "index" in the implementation, since a compiler will not always catch cases like

      (uint)index
      @@ -585,7 +585,7 @@ have been renamed to
       TQLabel::setIndent()
      and
       TQLabel::indent()
      , respectively. This was done to avoid -collision with TQFrame::setMargin(), which is now virtual. +collision with TQFrame::setMargin(), which is now virtual.

       TQLabel::setMovie()

      @@ -607,24 +607,24 @@ of your application, pass this main window as parent to the dialog's constructor. Old code (with 0 pointer) will still run. Old code that included TQDialogs as child widgets will no longer work (it never really did). If you think you might be doing this, put a breakpoint in -TQDialog::TQDialog() conditional on parent not being 0. +TQDialog::TQDialog() conditional on parent not being 0.

      TQStrList

      -

      Many methods that took a TQStrList can now instead take a TQStringList, -which is a real list of TQString values. +

      Many methods that took a TQStrList can now instead take a TQStringList, +which is a real list of TQString values.

      To use TQStringList rather than TQStrList, change loops that look like this:

      -    TQStrList list = ...;
      +    TQStrList list = ...;
           const char* s;
      -    for ( s = list.first(); s; s = list.next() ) {
      +    for ( s = list.first(); s; s = list.next() ) {
               process(s);
           }
       
      to be like this:
      -    TQStringList list = ...;
      +    TQStringList list = ...;
           TQStringList::ConstIterator i;
      -    for ( i = list.begin(); i != list.end(); ++i ) {
      +    for ( i = list.begin(); i != list.end(); ++i ) {
               process(*i);
           }
       
      @@ -633,14 +633,14 @@ to be like this:

      The following functions now use TQStringList rather than TQStrList for return types/parameters.

      @@ -650,13 +650,13 @@ choose to use encodedEntryList().
    • TQListBox::insertStringList(const TQStringList &,int index=-1)

    The rarely used static function void -TQFont::listSubstitutions(TQStrList*) is replaced by TQStringList -TQFont::substitutions(). +TQFont::listSubstitutions(TQStrList*) is replaced by TQStringList +TQFont::substitutions().

    TQLayout

    Calling resize(0,0) or resize(1,1) will no longer work magically. Remove all such calls. The default size of top level widgets will be their -sizeHint(). -

    The default implementation of TQWidget::sizeHint() will no longer +sizeHint(). +

    The default implementation of TQWidget::sizeHint() will no longer return just an invalid size; if the widget has a layout, it will return the layout's preferred size.

    The special maximum MaximumHeight/Width is now TQWIDGETSIZE_MAX, @@ -667,32 +667,32 @@ non-default alignment now indicates that the widget should not grow to fill the available space, but should be sized according to sizeHint(). If a widget is too small, set the alignment to 0. (Zero indicates no alignment, and is the default.) -

    The class TQGManager is removed. Subclasses of TQLayout need to be rewritten -to use the new, much simpler TQLayout API. +

    The class TQGManager is removed. Subclasses of TQLayout need to be rewritten +to use the new, much simpler TQLayout API.

    For typical layouts, all use of -setMinimumSize() +setMinimumSize() and -setFixedSize() +setFixedSize() can be removed. -activate() is no longer necessary. +activate() is no longer necessary.

    -You might like to look at the TQGrid, TQVBox, and TQHBox widgets - they offer +You might like to look at the TQGrid, TQVBox, and TQHBox widgets - they offer a simple way to build nested widget structures.

    TQListView

    In TQt 1.x mouse events to the viewport where redirected to the event handlers for the listview; in TQt 2.x, this functionality is -in TQScrollView where mouse (and other position-oriented) events are +in TQScrollView where mouse (and other position-oriented) events are redirected to viewportMousePressEvent() etc, which in turn translate the event to the coordinate system of the contents and call contentsMousePressEvent() etc, thus providing events in the most convenient coordinate system. If you overrode TQListView::MouseButtonPress(), -TQListView::mouseDoubleClickEvent(), TQListView::mouseMoveEvent(), or -TQListView::mouseReleaseEvent() you must instead override +TQListView::mouseDoubleClickEvent(), TQListView::mouseMoveEvent(), or +TQListView::mouseReleaseEvent() you must instead override viewportMousePressEvent(), viewportMouseDoubleClickEvent(), viewportMouseMoveEvent(), or viewportMouseReleaseEvent() respectively. New code will usually override contentsMousePressEvent() etc. -

    The signal TQListView::selectionChanged(TQListViewItem *) can now be +

    The signal TQListView::selectionChanged(TQListViewItem *) can now be emitted with a null pointer as parameter. Programs that use the argument without checking for 0, may crash.

    TQMultiLineEdit

    @@ -701,45 +701,45 @@ The protected function
     TQMultiLineEdit::textWidth(TQString*)
    changed to -
     TQMultiLineEdit::textWidth(const TQString&)
    +
     TQMultiLineEdit::textWidth(const TQString&)
    . This is unlikely to be a problem, and you'll get a compile error if you called it.

    TQClipboard

     TQClipboard::pixmap()
    - now returns a TQPixmap, not a TQPixmap*. + now returns a TQPixmap, not a TQPixmap*. The pixmap -will be null if no pixmap is on the -clipboard. TQClipboard now offers powerful MIME-based types on the +will be null if no pixmap is on the +clipboard. TQClipboard now offers powerful MIME-based types on the clipboard, just like drag-and-drop (in fact, you can reuse most of your drag-and-drop code with clipboard operations).

    TQDropSite

    TQDropSite is obsolete. If you simply passed this, just remove the inheritance of TQDropSite and call -setAcceptDrops(TRUE) in the class +setAcceptDrops(TRUE) in the class constructor. If you passed something other than this, your code will not work. A common case is passing the -viewport() of a TQListView, +viewport() of a TQListView, in which case, override the -contentsDragMoveEvent(), +contentsDragMoveEvent(), etc. functions rather than TQListView's dragMoveEvent() etc. For other cases, you will need to use an event filter to act on the drag/drop events of another widget (as is the usual way to intercept foreign events).

    TQScrollView

    The parameters in the signal -contentsMoving(int,int) +contentsMoving(int,int) are now positive rather than negative values, coinciding with -setContentsPos(). Search for +setContentsPos(). Search for connections you make to this signal, and either change the slot they are connected to such that it also expects positive rather than negative values, or introduce an intermediate slot and signal that negates them. -

    If you used drag and drop with TQScrollView, you may experience the problem +

    If you used drag and drop with TQScrollView, you may experience the problem described for TQDropSite.

    TQTextStream

    @@ -759,7 +759,7 @@ identifiers affected by the Url to Uri change are TQUrlDrag::setUrls() and TQUrlDrag::urlToLocalFile().

    TQPainter

    The GrayText painter flag has been removed. Use -setPen( palette().disabled().foreground() ) +setPen( palette().disabled().foreground() ) instead.

    The RasterOp enum (CopyROP, @@ -782,7 +782,7 @@ NorROP, LastROP) is now part of the TQt namespace class, so if you use it outside a member function, you'll need to prefix with TQt::.

    TQPicture

    -

    The binary storage format of TQPicture is changed, but the TQt 2.x +

    The binary storage format of TQPicture is changed, but the TQt 2.x TQPicture class can both read and write TQt 1.x format TQPictures. No special handling is required for reading; TQPicture will automatically detect the version number. In order to write a TQt 1.x format TQPicture, @@ -794,11 +794,11 @@ href="#TQDataStream">TQDataStream applies. 1.x. The program will not crash, it will just issue the warning "TQPicture::play: Incompatible version 2.x" and refuse to load the picture. -

    TQPoint, TQPointArray, TQSize and TQRect

    +

    TQPoint, TQPointArray, TQSize and TQRect

    The basic coordinate datatype in these classes, TQCOORD, is now 32 bit (int) instead of a 16 bit (short). The const values TQCOORD_MIN and TQCOORD_MAX have changed accordingly. -

    TQPointArray is now actually, not only seemingly, a TQArray of TQPoint +

    TQPointArray is now actually, not only seemingly, a TQArray of TQPoint objects. The semi-internal workaround classes TQPointData and TQPointVal are removed since they are no longer needed; TQPoint is used directly instead. The function

     TQPointArray::shortPoints()
    @@ -806,7 +806,7 @@ instead. The function
     TQPointArray::shortPoints()
    provides the point array converted to short (16bit) coordinates for use with external functions that demand that format.

    TQImage

    -

    TQImage uses TQRgb for the colors - see the changes to that. +

    TQImage uses TQRgb for the colors - see the changes to that.

    TQPixmap

     TQPixmap::convertToImage()
    with bitmaps now guarantees that color0 pixels @@ -826,10 +826,10 @@ or - see the documentation to choose which is best for your application. NormalOptim is most like the TQt 1.x "TRUE" optimization. -

    TQMenuData / TQPopupMenu

    +

    TQMenuData / TQPopupMenu

    In TQt 1.x, new menu items were assigned either an application-wide unique identifier or an identifier equal to the index of the item, depending on the -insertItem(...) function used. +insertItem(...) function used. In TQt 2.x this confusing situation has been cleaned up: generated identifiers are always unique across the entire application. @@ -850,27 +850,27 @@ ownership manually. locations within one menu structure or be used as both a menubar drop-down and as a context popup-menu. This should make it possible to significantly simplify many applications. -

    Last but not least, TQPopupMenu no longer inherits TQTableView. Instead, -it directly inherits TQFrame. -

    TQValidator (TQLineEdit, TQComboBox, TQSpinBox)

    +

    Last but not least, TQPopupMenu no longer inherits TQTableView. Instead, +it directly inherits TQFrame. +

    TQValidator (TQLineEdit, TQComboBox, TQSpinBox)

     TQValidator::validate(...)
    and -
     TQValidator::fixup( TQString & )
    +
     TQValidator::fixup( TQString & )
    are now const functions. If your subclass reimplements validate() as a non-const function, you will get a compile error (validate was pure virtual).

    In TQLineEdit, TQComboBox, and TQSpinBox, -setValidator(...) now takes a const pointer to a TQValidator, and +setValidator(...) now takes a const pointer to a TQValidator, and validator() returns a const pointer. This change highlights the fact that the widgets do not take the ownership of the validator (a validator is -a TQObject on its own, with its own parent - you can easily set the same validator +a TQObject on its own, with its own parent - you can easily set the same validator object on many different widgets), so changing the state of such an object or deleting it is very likely a bug. -

    TQFile, TQFileInfo, TQDir

    -

    File and directory names are now always Unicode strings (ie. TQString). If you used TQString +

    TQFile, TQFileInfo, TQDir

    +

    File and directory names are now always Unicode strings (ie. TQString). If you used TQString in the past for the simplicity it offers, you'll probably have little consequence. However, if you pass filenames to system functions rather than using TQt functions (eg. if you use the Unix unlink() function rather than TQFile::remove(), your code will probably @@ -888,12 +888,12 @@ boundingRect(TQChar), but since char auto-converts to TQChar, you're not likely to run into problems with this.

    TQWindow

    -

    This class (which was just TQWidget under a different name) has been +

    This class (which was just TQWidget under a different name) has been removed. If you used it, do a global search-and-replace of the word "TQWindow" with "TQWidget".

    TQEvent

    -

    The global #define macros in qevent.h have been replaced by an -enum in TQEvent. Use e.g. TQEvent::Paint instead of Event_Paint. Same +

    The global #define macros in ntqevent.h have been replaced by an +enum in TQEvent. Use e.g. TQEvent::Paint instead of Event_Paint. Same for all of: Event_None, Event_Timer, @@ -931,7 +931,7 @@ Event_ActivateControl, Event_DeactivateControl, and Event_User. -

    The Q_*_EVENT macros in qevent.h have been deleted. Use an +

    The Q_*_EVENT macros in ntqevent.h have been deleted. Use an explicit cast instead. The macros were: Q_TIMER_EVENT, Q_MOUSE_EVENT, @@ -951,7 +951,7 @@ much testing of its values.

    All the removed functions

    All these functions have been removed in TQt 2.x. Most are simply cases where "const char*" has changed to -"const TQString&", or when an enumeration type has moved into the TQt:: +"const TQString&", or when an enumeration type has moved into the TQt:: namespace (which, technically, is a new name, but your code will compile just the same anyway). This list is provided for completeness.

    -- cgit v1.2.1