Results 1 to 2 of 2

Thread: Simple display of an image

  1. #1
    Join Date
    Jan 2007
    Posts
    91
    Thanks
    21
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Simple display of an image

    Hello,
    Another really dumb question. I need to display a standard image (.jpg, .bmp, etc.) as a title in a window. I think that the label can do this, but I can't figure out how to set it up to display a pixmap.

    Where can I find some simple code that shows me how to load an image and display it in a dialog?
    - BRC

  2. #2
    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: Simple display of an image

    Qt Code:
    1. QDialog dlg;
    2. QHBoxLayout *l = new QHBoxLayout(&dlg);
    3. QLabel *label = new QLabel;
    4. l->addWidget(label);
    5. label->setPixmap(QPixmap("/usr/share/icons/crystalsvg/128x128/apps/tux.png"));
    6. dlg.exec();
    To copy to clipboard, switch view to plain text mode 

  3. The following 2 users say thank you to wysota for this useful post:

    bruccutler (16th January 2007), VireX (16th January 2007)

Similar Threads

  1. Qt Image Display...
    By mahe2310 in forum Qt Programming
    Replies: 9
    Last Post: 22nd July 2013, 09:06
  2. how i can add image in my toolbar
    By jyoti in forum Qt Tools
    Replies: 7
    Last Post: 19th December 2006, 14:39
  3. How and when to repaint a widget ?
    By yellowmat in forum Newbie
    Replies: 7
    Last Post: 3rd April 2006, 16:36
  4. How to display a QByteArray as an Image ?
    By probine in forum Newbie
    Replies: 7
    Last Post: 3rd April 2006, 13:45
  5. How to display listbox, texbox etc over an image.
    By mahe2310 in forum Qt Programming
    Replies: 12
    Last Post: 3rd March 2006, 15:51

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.