我不熟悉 PyQt 和 QColumnView,我该如何做才能获得用户选择的任何内容的“描述”,而不是我可以单击扩展列视图的另一行项目?
class Ui_MainWindow(object):
def setupUi(self, MainWindow):
MainWindow.setObjectName("MainWindow")
MainWindow.resize(423, 390)
self.centralwidget = QtWidgets.QWidget(MainWindow)
self.centralwidget.setObjectName("centralwidget")
self.add_btn = QtWidgets.QPushButton(self.centralwidget)
self.add_btn.setGeometry(QtCore.QRect(334, 345, 75, 23))
self.add_btn.setObjectName("add_btn")
self.auto_btn = QtWidgets.QPushButton(self.centralwidget)
self.auto_btn.setGeometry(QtCore.QRect(245, 345, 81, 23))
self.auto_btn.setObjectName("auto_btn")
self.auto_num = QtWidgets.QLineEdit(self.centralwidget)
self.auto_num.setGeometry(QtCore.QRect(141, 346, 99, 20))
self.auto_num.setText("")
self.auto_num.setClearButtonEnabled(False)
self.auto_num.setObjectName("auto_num")
self.columnView = QtWidgets.QColumnView(self.centralwidget)
self.columnView.setGeometry(QtCore.QRect(10, 10, 399, 320))
self.columnView.setObjectName("columnView")
model = QtGui.QStandardItemModel()
for i in 'abcd':
group = QtGui.QStandardItem(i)
model.appendRow(group)
self.columnView.setModel(model)
MainWindow.setCentralWidget(self.centralwidget)
self.retranslateUi(MainWindow)
QtCore.QMetaObject.connectSlotsByName(MainWindow)
def retranslateUi(self, MainWindow):
_translate = QtCore.QCoreApplication.translate
MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow"))
self.add_btn.setText(_translate("MainWindow", "Add Item"))
self.auto_btn.setText(_translate("MainWindow", "Auto-populate"))
这就是我希望它出现的方式