Results 1 to 2 of 2

Thread: Displaying a QImage on the screen

  1. #1
    Join Date
    Apr 2010

    Question Displaying a QImage on the screen


    I have an unsigned char pointer to an image codified in 24 bits RGB. I tried to display it on the screen through the following code.

    void GLWidget::paintEvent(QPaintEvent *event)
    QImage qi(buff, 640, 480, QImage::Format_RGB888);
    QPainter painter;
    painter.drawImage(event->rect(), qi);

    When I execute this code, the screen is black. However, if I save the QImage to a *.png file and load it again, it works. The format of the QImage when I loaded from the file is QImage::Format_RGB32. I tried to convert the original one to this format, but still not working.

    Any ideas? Is there any other way to display an image on the screen?

    Thank you very much!

  2. #2
    Join Date
    Oct 2006
    New Delhi, India
    Thanked 334 Times in 317 Posts
    Qt products
    Unix/X11 Windows

    Default Re: Displaying a QImage on the screen

    The simplest way to show an image is through QLabel::setPixmap

Similar Threads

  1. Replies: 16
    Last Post: 29th March 2010, 07:05
  2. QImage displaying through OpenGL
    By strateng in forum Newbie
    Replies: 0
    Last Post: 23rd March 2010, 04:35
  3. Displaying Text on Black and White Screen
    By Stobie in forum Qt for Embedded and Mobile
    Replies: 4
    Last Post: 8th December 2009, 01:03
  4. Help displaying frames from a webcam to the screen
    By stealth86 in forum Qt Programming
    Replies: 2
    Last Post: 3rd July 2007, 18:48
  5. Replies: 3
    Last Post: 15th March 2006, 11:44

Tags for this Thread


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.