[Qt-interest] Adding an image to table cell (Tony Rietwyk)
Eade, Sean (SCR US)
sean.eade at siemens.com
Fri Jan 30 21:32:05 CET 2009
Hi Tony,
You were correct - I needed to change the code to - :/images/qt-logo.png
- so that it could find the image in the resources.
Thanks,
Sean.
Message: 5
Date: Fri, 30 Jan 2009 10:22:21 +1100
From: "Tony Rietwyk" <tony.rietwyk at rightsoft.com.au>
Subject: Re: [Qt-interest] Adding an image to table cell
To: <qt-interest at trolltech.com>
Message-ID: <FB1CDC6B335B43E4B939567566A7F3E6 at TonysLaptop2>
Content-Type: text/plain; charset="us-ascii"
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.trolltech.com/pipermail/qt-interest/attachments/20090130/3d
23dfd8/attachment.html
------------------------------
_______________________________________________
Qt-interest mailing list
Qt-interest at trolltech.com
http://lists.trolltech.com/mailman/listinfo/qt-interest
End of Qt-interest Digest, Vol 2, Issue 162
*******************************************
More information about the Qt-interest-old
mailing list