Wow, ok that was too early. Three typos, I am scared... But beside that, my first thought was also false. You have to do the drawing yourself.
class PointDelegate : public QStyledItemDelegate
{
public:
PointDelegate
(QObject *parent
= 0): QStyledItemDelegate
(parent
) {}
{
if (QVariant::Point == index.
data().
type()) {
painter->drawText(option.rect,
displayText
(index.
data(),
QLocale::system()),
option.displayAlignment);
}
else
QStyledItemDelegate::paint(painter, option, index);
}
{
Q_UNUSED(locale);
qDebug() << "Delegate called with " << value;
return QString("{%1,%2}").
arg(value.
toPoint().
x()).
arg(value.
toPoint().
y());
}
};
class PointDelegate : public QStyledItemDelegate
{
public:
PointDelegate(QObject *parent = 0): QStyledItemDelegate(parent)
{}
void paint( QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index ) const
{
if (QVariant::Point == index.data().type())
{
painter->drawText(option.rect,
displayText(index.data(), QLocale::system()),
option.displayAlignment);
}
else
QStyledItemDelegate::paint(painter, option, index);
}
QString displayText(const QVariant & value, const QLocale & locale ) const
{
Q_UNUSED(locale);
qDebug() << "Delegate called with " << value;
return QString("{%1,%2}").arg(value.toPoint().x()).arg(value.toPoint().y());
}
};
To copy to clipboard, switch view to plain text mode
Bookmarks