[Qt-interest] Adding an image to table cell

Tony Rietwyk tony.rietwyk at rightsoft.com.au
Fri Jan 30 00:22:21 CET 2009


Sean wrote:

I have been trying to add an image to a cell in a table I have, but it
doesn't seem to want to work for me.

This is the code I am using:

 

    QIcon icon;

    icon.addPixmap(QPixmap(QString::fromUtf8("images/qt-logo.png")),
QIcon::Normal, QIcon::Off);

 

    QTableWidgetItem *tickItem = new QTableWidgetItem ();

      tickItem->setIcon(icon);

    ui.tableWidget->setItem(0, 0, tickItem);

 

Any reason why this doesn't work.

I am using QT4.4.3.

 

Thanks,

Sean 

 

Hi Sean, 
 
Does QFile::exists("images/qt-logo.png") return true? Maybe the current
directory is not where you expect? 
 
Or is this a resource? Which would need ":/images/qt-logo.png". 
 
Regards, 
 
Tony.
 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090130/3d23dfd8/attachment.html 


More information about the Qt-interest-old mailing list