QStyledItemDelegate Draw/Call

276 views
Skip to first unread message

Ruchit Bhatt

unread,
Aug 11, 2017, 7:40:33 AM8/11/17
to Python Programming for Autodesk Maya

Hi,

need help to draw custom styled delegate for list view




















How to inject QPushButton, QRect, QLabel, etc. in QStyledItemDelegate paint() and how to trigger external function on delegate interaction.?


Justin Israel

unread,
Aug 11, 2017, 8:41:53 PM8/11/17
to Python Programming for Autodesk Maya

If you are going with a delegate then you need to paint it yourself. QStyle has the ability to draw controls in the way the actual QWidgets work. Another way could be to keep a private custom widget that you built to look like this, and using widget.render() to draw it onto your painter.

If that is too complex for you, then you could go with the QListWidget approach and set the widget for each item. Or you could manage a QVBoxLayout with your list of widgets. But that loses the ability to naturally be driven by a model.


--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/ce941c89-d711-4cd3-85f5-cee989f94697%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ruchit Bhatt

unread,
Aug 12, 2017, 3:02:51 AM8/12/17
to Python Programming for Autodesk Maya
Justin, QListWidget.setItemWidget is indeed useful. Thank you for pointing me towards it. Pls check the attached image which is a successful implementation on this technique.
On a different thought, i would still like to implement a modelView based workflow in order to benefit from managing data dynamically, any thoughts on that?


Justin Israel

unread,
Aug 12, 2017, 4:05:01 AM8/12/17
to Python Programming for Autodesk Maya


On Sat, Aug 12, 2017, 7:02 PM Ruchit Bhatt <ruchitinn...@gmail.com> wrote:
Justin, QListWidget.setItemWidget is indeed useful. Thank you for pointing me towards it. Pls check the attached image which is a successful implementation on this technique.
On a different thought, i would still like to implement a modelView based workflow in order to benefit from managing data dynamically, any thoughts on that?

Ya thats what I was saying in my previous reply. Using the delegate, you have to handle the paint routines yourself. So you can either use the QStyle approach to draw all your controls, or you can try using that custom widget as a private member for each delegate and calling render() to draw it onto the painter. 



--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages