Results 1 to 2 of 2

Thread: QTreeView and itemDelegate code

  1. #1
    Join Date
    Jul 2009
    Location
    Valladolid, Spain
    Posts
    125
    Thanks
    16
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default QTreeView and itemDelegate code

    This code worked just fine some months ago (maybe half year), and now it's not working. Why could it be? Message error is ''NoneType' object has no attribute 'style'' from line 12.

    Qt Code:
    1. def paint(self, painter, option, index):
    2. if not index.isValid():
    3. return
    4. painter.translate(0, 0)
    5. options = QStyleOptionViewItemV4(option)
    6. self.initStyleOption(options, index)
    7. painter.save()
    8. painter.setRenderHint(QPainter.Antialiasing, True)
    9. doc = QTextDocument()
    10. doc.setHtml(options.text)
    11. options.text = ""
    12. options.widget.style().drawControl(QStyle.CE_ItemViewItem, options, painter, options.widget) #<---ERROR
    13. painter.translate(options.rect.left() + self.sizeDp(index) + 3, options.rect.top()) #paint text right after the dp + 3pixels
    14. rect = QRectF(0, 0, options.rect.width(), options.rect.height())
    15. doc.drawContents(painter, rect)
    16. painter.restore()
    To copy to clipboard, switch view to plain text mode 

    Why could this be happening?

  2. #2
    Join Date
    Jul 2009
    Location
    Valladolid, Spain
    Posts
    125
    Thanks
    16
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QTreeView and itemDelegate code

    the solution was

    options.widget.style().drawControl(QStyle.CE_ItemV iewItem, options, painter, options.widget) #<---ERROR

    QApplication.style().drawControl(QStyle.CE_ItemVie wItem, options, painter, options.widget)

Similar Threads

  1. QTreeView and ItemDelegate style problem
    By Guilo in forum Qt Programming
    Replies: 0
    Last Post: 20th April 2010, 19:13
  2. ProxyModel and ItemDelegate work togather?
    By litterflybug in forum Qt Programming
    Replies: 0
    Last Post: 15th December 2009, 02:28
  3. Replies: 0
    Last Post: 2nd October 2009, 17:57
  4. Can I use a QWidget as a renderer in an ItemDelegate?
    By boblebel in forum Qt Programming
    Replies: 2
    Last Post: 2nd May 2009, 20:03
  5. Color table row with ItemDelegate
    By dexjam in forum Newbie
    Replies: 8
    Last Post: 29th June 2006, 12:56

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.