how can i create a QListWidgetItem that has 1 image and 2 labels/strings underneath, that have support for css?
this is the last thing i have tried:
class CustomListWidgetItem(QListWidgetItem, QLabel):
def __init__(self, parent=None):
QListWidgetItem.__init__(self, parent)
QLabel.__init__(self, parent)
i'm using PyQt btw
In this case, you can't (it actually has an API for adding icons easily, but two labels/strings is impossible). But, you can create your own custom widget and put it into
QtGui.QListWidget
.Create your custom widget.
Create your
QtGui.QListWidget
in the main application.Create a custom widget object and set item in
QListWidgetItem
byQListWidgetItem
is inQtGui.QListWidget
by using theQListWidget.setItemWidget (self, QListWidgetItem item, QWidget widget)
method.This is an example to explain my solution:
Note: I have image file
icon.png
, size 48 x 48 pixel.QListWidget.setItemWidget
Experimental result