I started out with the StarDelegate Item. To simplify the code I have the following class:
class StarRating
{
public:
StarRating(int starCount = 1)
{
myStarCount = starCount;
}
int starCount() const
{
return myStarCount;
}
void setStarCount(int starCount)
{
myStarCount = starCount;
}
private:
int myStarCount;
};
Q_DECLARE_METATYPE(StarRating)
#endif
And I do this:
QTableWidgetItem *item0 = new QTableWidgetItem;
item0->setData(0, qVariantFromValue(StarRating(3)));
StarRating is the custom class used by the StarDelegate to display a number as stars, the number of which a user can edit. I connected the SIGNAL (cellChanged(int, int)) to a function using signalMapper, that part works. the problem is I can’t access “the value” in the cell. For cells containing strings and ints QTableWidgetItempointer->text()->toInt(); or something like that works. How can I get the value in a cell that contains a custom like StarRating? To I use QTableWidgetItem::Data()? Do I override it somehow?
↧