Search code examples
pythonqtpyqtpyqt4qt-designer

Qt Designer QListWidget checkbox


I am using PyQt4 and Qt Designer. I have a QListWidget in which I populate after loading a file in my program.

I want to set it so that all items will be checkable, as opposed to just selectable. I have found online that this is a 'flag' of the QListWidget, however, in Qt Designer I can't see where to do this.

Is it possible?


Solution

  • You can do this by opening the edit list widget item tab , and look into the properties. and set the checkState property.

    enter image description here

    **UPDATE **

    item = QtGui.QListWidgetItem()
    item.setText(QtGui.QApplication.translate("Dialog", x, None,    QtGui.QApplication.UnicodeUTF8))
    item.setFlags(item.flags() | QtCore.Qt.ItemIsUserCheckable)
    item.setCheckState(QtCore.Qt.Unchecked)
    self.listWidget.addItem(item)