Results 1 to 5 of 5

Thread: How do i change images? Qt creator label>pixmap

  1. #1
    Join Date
    Feb 2010
    Posts
    2
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60

    Exclamation How do i change images? Qt creator label>pixmap

    I got errors with my code...

    ui->label->pixmap(":/new/prefix1/images/solve3.png");
    also got errors with this code...

    char[32] urr = ":/new/prefix1/images/solve3.png";
    ui->label->pixmap(urr);

    ERRORS:
    /Users/martins/showhide/mainwindow.cpp:31: error: no matching function for call to 'QLabel:ixmap(const char [32])'

    /Library/Frameworks/QtGui.framework/Headers/qlabel.h:75: note: candidates are: const QPixmap* QLabel:ixmap() const

  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: How do i change images? Qt creator label>pixmap

    its QLabel::setPixmap()
    Qlabel::Pixmap() returns you the current pixmap.

  3. #3
    Join Date
    Feb 2010
    Posts
    2
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60

    Default Re: How do i change images? Qt creator label>pixmap

    thanks, but this doesn't work either...

    ui->label->setPixmap(":/new/prefix1/images/FirefoxCool.png");
    C:/Users/QueenZ/Desktop/showhide/showhide/mainwindow.cpp:32: error: no matching function for call to 'QLabel::setPixmap(const char [37])'

    c:\Qt\2010.01\qt\include/QtGui/../../src/gui/widgets/qlabel.h:116: note: candidates are: void QLabel::setPixmap(const QPixmap&)

  4. #4
    Join Date
    Jun 2009
    Posts
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: How do i change images? Qt creator label>pixmap

    The function you want would be void QLabel::setPixmap(const QPixmap&)
    So I think you would need syntax that looks similar to this:
    Qt Code:
    1. QPixmap *pixmap = new QPixmap(":/new/prefix1/images/FirefoxCool.png");
    2. ui->label->setPixmap(pixmap);
    To copy to clipboard, switch view to plain text mode 
    I have not tested this nor have I ever used QPixmap so you may need to mess around with this a bit, but this should get you started.

  5. #5
    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: How do i change images? Qt creator label>pixmap

    or simply ui->label->setPixmap(QPixmap(":/new/prefix1/images/FirefoxCool.png") );

Similar Threads

  1. label - pixmap - problem
    By qwrhiobasdbgghoasdf in forum Newbie
    Replies: 5
    Last Post: 16th September 2010, 01:29
  2. PixMap XPM images NOT in .cpp fille ???
    By fassage in forum Qt Programming
    Replies: 0
    Last Post: 6th November 2009, 11:48
  3. How to change the Label text
    By grsandeep85 in forum Qt Programming
    Replies: 2
    Last Post: 15th September 2009, 13:57
  4. comparison of two pixmap images
    By sar_van81 in forum Qt Programming
    Replies: 5
    Last Post: 18th September 2007, 12:35
  5. Replies: 10
    Last Post: 1st February 2006, 11:08

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.