Results 1 to 2 of 2

Thread: Displaying a QImage on the screen

  1. #1
    Join Date
    Apr 2010
    Posts
    1

    Question Displaying a QImage on the screen

    Hello,

    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.begin(this);
    painter.drawImage(event->rect(), qi);
    painter.end();
    }

    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
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    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, 08:05
  2. QImage displaying through OpenGL
    By strateng in forum Newbie
    Replies: 0
    Last Post: 23rd March 2010, 05: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, 02:03
  4. Help displaying frames from a webcam to the screen
    By stealth86 in forum Qt Programming
    Replies: 2
    Last Post: 3rd July 2007, 19:48
  5. Replies: 3
    Last Post: 15th March 2006, 12:44

Tags for this Thread

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.