Quote Originally Posted by ChrisW67 View Post
This happens, presumably, because QVariant::isNull() calls QPoint::isNull() which returns true for QPoint(0,0).
That's probably the reason. A quick work around is:
Qt Code:
  1. #include <QtGui>
  2. #include <QDebug>
  3. class PointDelegate : public QStyledItemDelegate
  4. {
  5. public:
  6. PointDelegate(QObject *parent = 0): QStyledItemDelegate(parent) {};
  7.  
  8. void paint( QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index )
  9. {
  10. if (QVariant::Point == index.data().type())
  11. return displayText(index.data, QLocale::system());
  12. else
  13. return QStyledItemDelegate::paint(painter, option, index);
  14. }
  15.  
  16. virtual QString displayText(const QVariant & value, const QLocale & locale ) const
  17. {
  18. Q_UNUSED(locale);
  19. qDebug() << "Delegate called with " << value;
  20. return QString("{%1,%2}").arg(value.toPoint().x()).arg(value.toPoint().y());
  21. }
  22. };
To copy to clipboard, switch view to plain text mode