PDA

View Full Version : Drawing a small rect on each item of a QListWidget



franco.amato
14th October 2020, 02:00
Good morning,
I don't have enough experience on model/view.
I am reading docs but i can not find what I need.
I have elements of a QListWidget. Each element has a checkbox and a string.
I would draw a small colored rectangle between the checkbox and the string.
How can I do? I know I have to use delegate but I can not find a similar example.
Thanx to all,
Franco

d_stranz
14th October 2020, 18:15
You can specify a QIcon for each QListWidgetItem. Maybe you can create QIcon instances for each color and assign those? A lot easier than a delegate, and you would have to create a unique delegate for each color anyway unless you also added a custom data role to each item that specified the color.

However, I do not know if icons and check boxes can live together in the same item. It would be easy to try that experiment first before launching into designing a delegate.