I created a checkable qcombobox using the following code. Then, I applied the fusion style to make my program look better. However, doing so results in the checkboxes next to the items in my code to no longer be visible. How can I fix that?
class WindowGUI(QMainWindow):
def __init__(self, gui):
super().__init__()
self.initUI(gui)
def initUI(self, gui):
self.teacherSelect = TeacherSelect()
self.setCentralWidget(self.teacherSelect)
class TeacherSelect(QComboBox):
def __init__(self, parent):
super().__init__(parent)
self.parent = parent
self.initModel()
self.addTeachers()
def initModel(self):
self.number = 1
self.selecteds = []
self.teacherDataWids = []
self.view().pressed.connect(self.select)
def addTeachers(self):
self.source = {"id1" : "a", "id2" : "b"}
self.number = 0
for teacherID in self.source.keys():
self.addItem(self.source[teacherID])
teacherItem = self.model().item(self.number)
teacherItem.setData(teacherID)
teacherItem.setCheckState(Qt.Unchecked)
self.number += 1
def select(self, index):
pass
if __name__ == '__main__':
app = QApplication(sys.argv)
app.setStyle("fusion")
windowGUI = WindowGUI()
windowGUI.show()
sys.exit(app.exec_())
Aucun commentaire:
Enregistrer un commentaire