Results 1 to 3 of 3

Thread: setting image to QLabel in new thread

  1. #1
    Join Date
    Sep 2008
    Posts
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default setting image to QLabel in new thread

    Hi.
    I'm extending QFileDialog with preview support. When user clicked on the graphic file, image must be set to the QLabel. I doing it in new thread because loading big images is slow sometimes.
    QPixmap is not supported to creating in new threads. I'm loading file in QPicture:
    Qt Code:
    1. QPicture *pic = new QPicture;
    2. pic->load(file);
    To copy to clipboard, switch view to plain text mode 
    But it returned warning to console:
    Qt Code:
    1. QPicturePaintEngine::checkFormat: Incorrect header
    To copy to clipboard, switch view to plain text mode 
    and file is not loaded.
    Can't anybody help me with this problem?

    P.S. Sorry for my English.

  2. #2
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: setting image to QLabel in new thread

    you can try to load data from file in thread in QByteArray and then emit a signal which will return this QByteArray and then in GUI you can create QPIxmap.
    if you need example I can show it.

  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: setting image to QLabel in new thread

    Use QImage and not QPicture.

Similar Threads

  1. can Qlabel display a series of image one by one ?
    By jirach_gag in forum Qt Tools
    Replies: 3
    Last Post: 11th August 2008, 15:36
  2. Replies: 13
    Last Post: 18th February 2008, 00:20
  3. Set the image at the center in QLabel?
    By vishal.chauhan in forum Qt Programming
    Replies: 5
    Last Post: 20th August 2007, 14:07
  4. KDE/QWT doubt on debian sarge
    By hildebrand in forum KDE Forum
    Replies: 13
    Last Post: 25th April 2007, 06:13
  5. Replies: 10
    Last Post: 20th March 2007, 22:19

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.