Results 1 to 5 of 5

Thread: Display a jpg file in a widget.

  1. #1
    Join Date
    Oct 2007
    Posts
    9
    Thanks
    1
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Question Display a jpg file in a widget.

    Dear Everyone,
    How can we display a jpg file in a widget.
    I m using following code but there is no output .....
    QLabel *imageLabel;
    imageLabel = new QLabel(this,0);
    imageLabel->setGeometry ( locx,locy,w,h );
    imageLabel->setBackgroundRole(QPalette::Base);
    imageLabel->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored);
    imageLabel->setScaledContents(true);
    QImage image(mediaPath[currentIndex]);
    if (!image.isNull())
    {
    qDebug()<<"Image"<<mediaPath[currentIndex];
    }
    imageLabel->setPixmap(QPixmap::fromImage(image));

    Please if you have any idea about it give reply.
    Thanks:

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Display a jpg file in a widget.

    Do you have the QJPEG plugin? What does QImageReader::supportedImageFormats() return?

    P.S. Please, don't double-post.

  3. #3
    Join Date
    Oct 2007
    Posts
    9
    Thanks
    1
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Unhappy Problem in display image

    Hello Everyone,
    I m displaying a .jpg file in a widget through QLabel and QScrollerArea Class .
    But it does not display the .jpg files
    My coding is as following ..........
    Qt Code:
    1. QLabel *imageLabel;
    2. imageLabel = new QLabel;
    3. imageLabel->setBackgroundRole(QPalette::Base);
    4. imageLabel->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Fixed);
    5. imageLabel->setScaledContents(TRUE);
    6.  
    7. QImage image(mediaPath[currentIndex]);
    8. imageLabel->setPixmap(QPixmap::fromImage(image));
    9. imageLabel->resize(imageLabel->pixmap()->size());
    10. scrollArea->setBackgroundRole(QPalette::Dark);
    11. scrollArea->setWidget(imageLabel);
    12. scrollArea->setWidgetResizable(TRUE);
    To copy to clipboard, switch view to plain text mode 

    If anyone has any idea please reply it.
    Thanks in advance......................
    Last edited by wysota; 26th October 2007 at 15:41. Reason: missing [code] tags

  4. #4
    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: Problem in display image

    Does it display PNG files? If so, look here: http://www.qtcentre.org/forum/faq.ph...missing_images

  5. #5
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Problem in display image

    Please, don't start more than one thread on the same problem.

Similar Threads

  1. qt-3.3.8 fail in scratchbox
    By nass in forum Installation and Deployment
    Replies: 0
    Last Post: 25th May 2007, 16:21
  2. Replies: 4
    Last Post: 10th March 2007, 19:01
  3. QWidget display on 2 stack widget page
    By spawnwj in forum Qt Programming
    Replies: 3
    Last Post: 4th September 2006, 13:07
  4. Replies: 3
    Last Post: 12th April 2006, 09:20

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.