【发布时间】:2021-05-31 08:28:57
【问题描述】:
我正在寻找一些代码,使我能够获取组合框的信息,我将它放在 QtDesigner 创建的 TableView 上。
由于缺乏知识,我没有使用任何课程或代表。当我使用 TableWidget 时,TableWidget.cellWidget(indexofthecurrentrow, 4).currentIndex() == 0 行向我返回了允许我更新数据库的行的当前状态,但由于模型或没有代表,我假设该行在 TableView 上不起作用。
相关代码如下:
for row in range(len(data_from_sqlite)):
comboBox = QComboBox()
comboBox.addItems('opt1', 'opt2')
index_combo = tableview.model().index(row, 5)
tableview.setIndexWidget(index_combo, comboBox)
我只是不知道如何通过按钮中连接的其他功能来检索此 QComboBox 状态。 我都试过了
tableview.model().index(0,4).itemData().currentIndex() #crashes
和
tableview.model().index(0,4).data() #returns None
提前感谢您的帮助。
【问题讨论】:
标签: python combobox pyqt pyqt5 qtableview