Results 1 to 2 of 2

Thread: label with image and text

  1. #1
    Join Date
    Oct 2007
    Location
    Italy
    Posts
    172
    Thanks
    39
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default label with image and text

    Hello, i'd like to set on a label an image and a text, i tried in this way but i'm not able to see the text, the Gui show me just the label.
    Qt Code:
    1. QLabel * label;
    2. label->setPixmap(QPixmap(QString::fromUtf8 ( ":/images/my.png" )));
    3. label->setText( tr ("Terminal settings") );
    To copy to clipboard, switch view to plain text mode 
    thx

  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: label with image and text

    A single label shows either text or a pixmap by default (not both at once). Either use two labels or set a richt text string on the label that contains a pixmap:
    Qt Code:
    1. label->setText(tr("<img src=\":/images/my.png\"/> Terminal settings"));
    To copy to clipboard, switch view to plain text mode 

  3. The following user says thank you to wysota for this useful post:

    mattia (7th March 2008)

Similar Threads

  1. QPushButton with image - text alignment
    By vladeck in forum Newbie
    Replies: 3
    Last Post: 1st July 2009, 20:20
  2. label Text is not changing using Qt Linguist
    By thomasjoy in forum Qt Tools
    Replies: 59
    Last Post: 8th October 2007, 16:24
  3. How to mirror-image text?
    By WinchellChung in forum Newbie
    Replies: 11
    Last Post: 31st July 2007, 18:13

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.