Results 1 to 7 of 7

Thread: QPoint(0,0) is not rendered with QStyledItemDelegate, bug or feature?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jun 2010
    Posts
    36
    Qt products
    Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QPoint(0,0) is not rendered with QStyledItemDelegate, bug or feature?

    I tried the workaround, It's not working for me. Sounds pretty reasonable what ChrisW67 said, in that case based on what grounds can Qt consider an origin point NULL? Should this be declared as a bug?
    Qt Code:
    1. QPoint test(0,0);
    2. if(test.isNull()){
    3. qDebug() << "Huh?";
    4. }
    5. // = Huh?
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Wiki edits
    5

    Default Re: QPoint(0,0) is not rendered with QStyledItemDelegate, bug or feature?

    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.
    Qt Code:
    1. class PointDelegate : public QStyledItemDelegate
    2. {
    3. public:
    4. PointDelegate(QObject *parent = 0): QStyledItemDelegate(parent)
    5. {}
    6.  
    7. void paint( QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index ) const
    8. {
    9. if (QVariant::Point == index.data().type())
    10. {
    11. painter->drawText(option.rect,
    12. displayText(index.data(), QLocale::system()),
    13. option.displayAlignment);
    14. }
    15. else
    16. QStyledItemDelegate::paint(painter, option, index);
    17. }
    18.  
    19. QString displayText(const QVariant & value, const QLocale & locale ) const
    20. {
    21. Q_UNUSED(locale);
    22. qDebug() << "Delegate called with " << value;
    23. return QString("{%1,%2}").arg(value.toPoint().x()).arg(value.toPoint().y());
    24. }
    25. };
    To copy to clipboard, switch view to plain text mode 

  3. #3
    Join Date
    Jun 2010
    Posts
    36
    Qt products
    Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QPoint(0,0) is not rendered with QStyledItemDelegate, bug or feature?

    Cool, did work now. Hey thanks for the help!

Similar Threads

  1. SVG rendered to an 8 bits indexed QImage ?
    By lauranger in forum Qt Programming
    Replies: 0
    Last Post: 23rd March 2009, 21:44
  2. changing svg graphic attributes once rendered
    By barrygp in forum Qt Programming
    Replies: 0
    Last Post: 13th December 2008, 02:09
  3. Programmatically Save Image rendered in a QWebPage
    By last2kn0 in forum Qt Programming
    Replies: 1
    Last Post: 24th November 2008, 06:33
  4. Webkit rendered fonts
    By carl in forum Qt Programming
    Replies: 0
    Last Post: 5th September 2008, 16:49
  5. QPoint Limitation
    By archanasubodh in forum Qt Programming
    Replies: 1
    Last Post: 5th August 2008, 10:22

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.