PDA

View Full Version : making up a QTableWidgetItem



chaosgeorge
22nd November 2006, 06:27
Hi, i want to customize a QTableWidgetItem after created but i get segmentation faults when retrieving the currentItem from a QTableWidget like this



aList->setItem(aList->rowCount()-2,
1,
new QTableWidgetItem(tr("TOTAL :: ")));
aList->currentItem()->setForeground(QBrush(Qt::darkRed));


why i can't use the QTWI returned by currentItem()? is there any way to do what im pretending the short way instead of creating the QTWI pointer and defining it before calling setItem()?

thanks

jpn
22nd November 2006, 06:36
Does the QTableWidget contain focus by the time retrieving the current item?
There's a difference between a "selected item" and a "current item". See this post (http://www.qtcentre.org/forum/f-qt-programming-2/t-what-is-currentitem-668.html#3). It discusses about a tree widget but the same thing goes with a table widget.