PDA

View Full Version : Icon, in front of QTableWidget row



Nazgul
28th April 2011, 18:12
Hello,

What I'm trying to do is having a small icon in front of a row in a QTableWidget. This is the code I've so far:


QTableWidgetItem * test = new QTableWidgetItem("00400000");
test->setBackground(QBrush(Qt::green));
QIcon qilel(":/Resources/red_arrow.png");
test->setIcon(qilel);
ui.SendList->setItem(0,1,test);

the qilel value of QIcon, is my code + resource map and then the red_arrow is the png I would like to add. The prolbme is that I don't see any Icon

Further when I use verticalHeader()->hide(); for the table will this still work, if I get this to work anyways.

Thanks,

aamer4yu
28th April 2011, 19:13
is the image file present in given location ??

Nazgul
28th April 2011, 19:18
euhm, yes its in the resource map.

Nazgul
29th April 2011, 15:54
Bumb with info

I found out that I can get it to work with the Qt Designer.

Normally the vertical header has 1,2,3,4,5,6, etc for the row. I want to change the number sometimes for a icon and sometimes hide it.

What I tried

i.SendList->verticalHeaderItem(5)->setIcon(qilel);

This does not work, but it crashes with: "unhandled expcetion at ..... Acces violation reading location ...."


Also,

ui.ButIgnore->setIcon(qilel);
ui.ButIgnore->setIconSize(QSize(5,5));

this si to test if the gilel has a picture inside it, the button stays white, ideas?

Grz