PDA

View Full Version : QTableWidgetItem: setData or setText?



mattc
5th January 2010, 18:13
Hello,
I am wondering what's the difference between


myTableWidgetItem->setData(Qt::DisplayRole, "hello");

and


myTableWidgetItem->setText("hello");

when adding new items to a QTableWidget... I tried both approaches and cannot tell the difference. Which one should I choose?

(edit: also, it looks like setTextAlignment() works on both)

Thank you

spirit
5th January 2010, 18:34
there is no difference between these two code snippets.
since


inline void QTableWidgetItem::setText(const QString &atext)
{ setData(Qt::DisplayRole, atext); }

the last one is simpler.