QStyleItemDelegate
-
I need to create a project in which there is a QTableView that contains cell with some drawings, these drawings have to change size at run time when the variables of the model change. I have seen that I can use QStyleItemDelegate but I do not know how to use it. I do not know what methods I need to overwrite, since I do not want to edit the cells manually, only to have them repaint when the model data changes. In each cell I need to show a circle that changes size according to the data of the model. I need your help please.
-
@juaniyoalm
When I do that I make a QStyleItemDelegate and just override the paint and sizeHint methods.
There may be an easier way to do it but I don't know what it is. Someone else might suggest an easier way though. -
Did you see the examples in Qt installation example directory ?
widgets/itemviews/spinboxdelegate/delegate.cpp: widgets/itemviews/stardelegate/stardelegate.cpp:
-
This examples aren't wright for me. I wanna redrawing cell, not edit.
-
@juaniyoalm said in QStyleItemDelegate:
This examples aren't wright for me
They are. Strardelegate in particular. @mrjj gave you a working example of your solution already: https://forum.qt.io/topic/96545/insert-fill-circle-into-cell-of-qtablewidget
-
@juaniyoalm
Like I said, just override the paint and sizeHint functions and you can do what you want.