Results 1 to 2 of 2

Thread: setText and setPixmap functions

  1. #1
    Join Date
    Jan 2016
    Posts
    7
    Thanks
    1
    Qt products
    Qt5

    Default setText and setPixmap functions

    Hi,
    I am using setText function and setPixmap functions to show png icons and some values like this :
    Qt Code:
    1. ui->label->setText(value);
    To copy to clipboard, switch view to plain text mode 
    Qt Code:
    1. QPixmap pix1(":/resources/images/images/01n.png");
    2. ui->label_2->setPixmap(pix1);
    To copy to clipboard, switch view to plain text mode 

    I want to combine both of them in one setText function like this:

    Qt Code:
    1. ui->label_3->setText(pix1 + value);
    To copy to clipboard, switch view to plain text mode 

    How can i do this?

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: setText and setPixmap functions

    How can i do this?
    Obviously, you can't. A QString is not a QPixmap and a QPixmap is not a QString. What could possibly be the meaning in C++ of adding together a text string and an image as an argument to a function call which expects a QString? You call QLabel::setText() with the string and QLabel::setPixmap() with the image.
    Last edited by d_stranz; 10th February 2016 at 18:12.

Similar Threads

  1. setPixmap crash (in a thread)
    By truegladiator in forum Newbie
    Replies: 1
    Last Post: 21st February 2011, 17:01
  2. What's the problem with setPixmap?
    By yagabey in forum Qt Programming
    Replies: 4
    Last Post: 21st November 2008, 17:34
  3. setPixmap cause assertion?
    By Equilibrium in forum Qt Programming
    Replies: 3
    Last Post: 23rd October 2007, 01:34
  4. setPixmap
    By mgurbuz in forum Qt Programming
    Replies: 9
    Last Post: 13th July 2007, 14:37
  5. QTreeWidget - setPixmap???
    By durbrak in forum Qt Programming
    Replies: 12
    Last Post: 10th October 2006, 07:57

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.