Results 1 to 3 of 3

Thread: QImage constructor

  1. #1
    Join Date
    Jan 2006
    Posts
    122
    Thanks
    16
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default QImage constructor

    Hello,
    I'm just trying to create a Qimage passing a buffer or ARGB.
    So I tried this:
    Qt Code:
    1. uchar* testB = new uchar[384*288*4];
    2. QImage image = QImage((uchar*) testB, 384, 288, QImage::Format_ARGB32);
    To copy to clipboard, switch view to plain text mode 

    On the second line I get an error and it occurs when in the QImage constructor
    I access d->depth (set on 0 at the first line):

    Qt Code:
    1. QImage::QImage(uchar* data, int width, int height, Format format)
    2. {
    3. d = 0;
    4. const int depth = depthForFormat(format);
    5. const int bytes_per_line = ((width * d->depth + 31)/32) * 4;
    To copy to clipboard, switch view to plain text mode 

    Am I doing something wrong or it's a QT bug? (I'm using 4.2.1)

    thanks

    bye

  2. #2
    Join Date
    Jan 2006
    Posts
    25
    Thanked 1 Time in 1 Post
    Qt products
    Qt3
    Platforms
    Unix/X11 Windows

    Default Re: QImage constructor

    Hi,

    If you set d to 0, you cannot access any member of d. I assume your program crashes when you run d->depth. What is the type of d? Why do you initialise it to be 0?

    Ellen

  3. #3
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: QImage constructor

    Try re-downloading Qt. I recall this bug. Upon releasing, the Trolls accidentally uploaded a wrong version of Qt (having the QImage bug) to their servers. It was soon later fixed to the correct package, but all users who managed to download the package during that time were affected by the bug. Are you even able to launch Qt Assistant and Designer? As far as I remember, the bug even prevented either one or both of them from starting up.

    EDIT: By the way, I'm 100% sure the bug was listed on the Task Tracker. I can't find it anymore, though...

    Quote Originally Posted by edb View Post
    If you set d to 0, you cannot access any member of d. I assume your program crashes when you run d->depth. What is the type of d? Why do you initialise it to be 0?
    It's QImage's constructor. Not his own code. d is a pointer to the private implementation.
    Last edited by jpn; 11th January 2007 at 12:09. Reason: updated contents
    J-P Nurmi

Similar Threads

  1. [Qt4] How to load Url image into QImage?
    By Gonzalez in forum Qt Programming
    Replies: 6
    Last Post: 13th October 2014, 10:10
  2. Replies: 7
    Last Post: 28th January 2007, 11:07
  3. Killing a Window in its constructor
    By hardgeus in forum Qt Programming
    Replies: 6
    Last Post: 15th December 2006, 18:31
  4. QPainter and QImage
    By beerkg in forum Newbie
    Replies: 3
    Last Post: 7th September 2006, 14:48
  5. use libs under qt4
    By raphaelf in forum Qt Programming
    Replies: 6
    Last Post: 27th February 2006, 17:59

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.