MitchellKehn
6/7/2018 - 12:50 PM

Add QWidget to QListWidget

Adds a given QWidget subclass into a QListWidget.

def add_widget_to_listwidget(widget, list_widget):
    """add a widget to a listwidget"""
    listitem = QtWidgets.QListWidgetItem()
    listitem.setSizeHint(widget.sizeHint())

    list_widget.addItem(listitem)
    list_widget.setItemWidget(listitem, widget)