Qt Designer QListWidget checkbox
14,275
You can do this by opening the edit list widget item tab , and look into the properties. and set the checkState property.
**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)
Author by
user-2147482637
Interested in programming with python. Looking to learn more about robots, math, and programming
Updated on June 11, 2022Comments
-
user-2147482637 almost 2 years
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?
-
user-2147482637 about 10 yearsokay i see that now, but thats only after you make an item. I dont have any items in my list. I populate the list after the program starts, so the checkboxes are not for individual items but for all items that will be in that listwidget
-
thecreator232 about 10 years@user1938107 : share the code that you use to load the gui and how you populate the itemwidget
-
user-2147482637 about 10 yearsi have a list widget, it is called myListwidget, and i populate it by self.myListwidget.addItem(someString)
-
user-2147482637 about 10 yearsso addItem just auto creates the QListWidgetItem() without needing to specify it but then doesnt allow for setting the flags? It would make sense for qt to just have an option for all items in a list to be checkable upon creation