Its basically pretty simple. I need to put QPoints in my QStandardItemModel, and to render them in the QTableView I sub-classed the QStyledItemDelegate and customized the displayText method to:
{
Q_UNUSED(locale);
return QString("{%1,%2}").
arg(value.
toPoint().
x()).
arg(value.
toPoint().
y());
}
virtual QString displayText(const QVariant & value, const QLocale & locale ) const
{
Q_UNUSED(locale);
return QString("{%1,%2}").arg(value.toPoint().x()).arg(value.toPoint().y());
}
To copy to clipboard, switch view to plain text mode
So far so good. It worked perfectly after I setted the Delegate for the specific column containing QPoints:
tableView->setItemDelegateForColumn(1, pointDelegate);
tableView->setItemDelegateForColumn(1, pointDelegate);
To copy to clipboard, switch view to plain text mode
Now, for some weird, weird reason the displayText method is not entering when the model has a point with zero on both coordinates. It does nothing to do with the QVariant or parsing the value cause I can confirm its just not entering the method at all.
Why is that? Looks like a bug to me.
Bookmarks