Results 1 to 3 of 3

Thread: Qlabel with (icon and text) HowTo ?

  1. #1
    Join Date
    Jul 2006
    Posts
    36
    Thanks
    8
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Qlabel with (icon and text) HowTo ?

    hi all

    how can i make a qlabel containing a text and an icon in the same time. I know that you can make one of them but what about twice.

    thanks

  2. #2
    Join Date
    Jan 2006
    Location
    Mountain View, CA
    Posts
    279
    Thanked 42 Times in 37 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Qlabel with (icon and text) HowTo ?

    Two ways:

    1. Just use two QLabels next to each other in a QVBoxLayout

    2. Use rich text for the label, e.g:

    Qt Code:
    1. lbl->setTextFormat(Qt::RichText);
    2. lbl->setText("<img src=":/myimage.png">Hello!");
    To copy to clipboard, switch view to plain text mode 

    You will need to have a resource collection set up that contains your image for (2).
    Save yourself some pain. Learn C++ before learning Qt.

  3. The following 4 users say thank you to Chicken Blood Machine for this useful post:

    mchrk (3rd September 2008), QiT (8th August 2006), skrzypu (13th May 2010), vycke (9th April 2008)

  4. #3
    Join Date
    Jul 2006
    Posts
    36
    Thanks
    8
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Qlabel with (icon and text) HowTo ?

    thanks nice solutions

Similar Threads

  1. Icon Text Alignment
    By nupul in forum Newbie
    Replies: 3
    Last Post: 1st May 2006, 04:47

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.