Results 1 to 2 of 2

Thread: QT4.3, addPix, QImage, and

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,373
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    3
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: QT4.3, addPix, QImage, and

    Quote Originally Posted by gpratt View Post
    1) QGraphicsScene::addPixmap (or maybe QPixmap::fromImage) does not seem to work. When I display a pixmap using "setBackgroundBrush" it seems to work correctly, but when displaying it with addPixmap, it displays totally distorted. See "Code 1", below
    QPixmap::fromImage() is a static method returning the pixmap created from the image, so your code should be:
    Qt Code:
    1. QPixmap mypixmap=QPixmap::fromImage(myimage);
    To copy to clipboard, switch view to plain text mode 

    2) There seems to be a problem creating an image with 8-bit indexed pixels. In fact, the sample code in the documentation does not work. Running the "Code 2", below results in error messages indicating that indexes 0, 1 and 2 are invalid. Stepping into the QT code seems to indicate that NumColors is not being properly set by the constructor (adding setNumColors(256) corrects the problem).
    If you use indexed images, you have to first set the colour lookup table size using QImage::setNumColors().

    3) Why does Valgrind return so many problems with QT? (QT4 is MUCH better than qt3, but still has plenty of issues).
    If you look closely, you'll notice that the problems are not related to Qt itself but to 3rd party libraries it uses (X11, libpng, etc.). AFAIK there are no memory problems with Qt.

  2. The following user says thank you to wysota for this useful post:

    gpratt (14th June 2007)

Similar Threads

  1. Replies: 12
    Last Post: 7th September 2011, 16:37

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.