- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在使用 QCompleter 在 PyQt5 中编写一个带有编辑字段的 GUI,以允许用户从弹出列表中选择输入。该列表内置于 QStandardItem 中并提供给 QCompleter。当用户从弹出列表中选择一个项目时,我需要的是 QStandardItem 模型中的行的索引。
我尝试研究文档 https://doc.qt.io/qt-5/qcompleter.html并找到一个名为
的部分迭代完成要检索单个候选字符串,请使用需要完成的文本调用 setCompletionPrefix() 并调用 currentCompletion()。
这对我来说没有用,因为我的 QStandardItem 模型中存在重复项目的风险,例如['猫,'猫','狗']。根据用户选择第一只猫还是第二只猫,有两个不同的 ID 与之关联。因此,获取用户选择的项目的 QStandardItem 模型的索引非常重要。
self.model = QtGui.QStandardItemModel()
#Merge the lists Id, IdCompound, self.SCL_Name together using zip. Id, IdCompount are int, while self.SCL_Name is str
ziplist1 = list(zip(Id, IdCompound, self.SCL_Name))
ziplist2 = list(zip(Id, IdCompound, self.SCL_OtherNames))
#Append the fields in ziplist1 and ziplist2 into
for name in ziplist1:
row = list()
for col in name:
cell = QtGui.QStandardItem(col) #Has made sure that everything is a string
row.append(cell)
self.model.appendRow(row)
for name in ziplist2:
row = list()
for col in name:
cell = QtGui.QStandardItem(col)
row.append(cell)
self.model.appendRow(row)
self.completer = QtWidgets.QCompleter()
self.completer.setModel(self.model)
self.completer.setCaseSensitivity(QtCore.Qt.CaseInsensitive)
self.completer.activated.connect(self.complete_excipient_input)
self.completer.setCompletionColumn(2)
我应该在 self.completer.activated.connect(self.complete_excipient_input) 中做什么才能获取与用户所选项目相对应的 self.model 中的索引?
编辑
我尝试运行@eyllanesc提供的代码示例,它工作正常。但是,当我将代码应用到我自己的代码中时,我收到错误消息,指出 QObject::connect: Cannot connect QCompleter::activated(QModelIndex) to
(null)::onActivated(QModelIndex)
和 发生异常:类型错误 activate(QModelIndex) 和 onActivated() 之间的 connect() 失败
下面是我的代码。它在 QtDesigner 中生成,随后转换为 python 代码。
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'main_v01.ui'
#
# Created by: PyQt5 UI code generator 5.9.2
#
# WARNING! All changes made in this file will be lost!
from PyQt5 import QtCore, QtGui, QtWidgets
import EBM_DB_tools as tool
class Ui_mainWindow(object):
def setupUi(self, mainWindow):
mainWindow.setObjectName("mainWindow")
mainWindow.resize(1195, 818)
mainWindow.setWindowOpacity(2.0)
mainWindow.setAutoFillBackground(False)
mainWindow.setToolButtonStyle(QtCore.Qt.ToolButtonFollowStyle)
self.centralwidget = QtWidgets.QWidget(mainWindow)
self.centralwidget.setObjectName("centralwidget")
self.lineedit_api = QtWidgets.QLineEdit(self.centralwidget)
self.lineedit_api.setGeometry(QtCore.QRect(30, 130, 143, 26))
font = QtGui.QFont()
font.setFamily("Arial")
font.setPointSize(12)
self.lineedit_api.setFont(font)
self.lineedit_api.setObjectName("lineedit_api")
self.pb_apiinsert = QtWidgets.QPushButton(self.centralwidget)
self.pb_apiinsert.setGeometry(QtCore.QRect(630, 130, 75, 26))
font = QtGui.QFont()
font.setFamily("Arial")
font.setPointSize(12)
self.pb_apiinsert.setFont(font)
self.pb_apiinsert.setAutoFillBackground(False)
self.pb_apiinsert.setObjectName("pb_apiinsert")
self.api_amount = QtWidgets.QLineEdit(self.centralwidget)
self.api_amount.setGeometry(QtCore.QRect(178, 130, 142, 26))
font = QtGui.QFont()
font.setFamily("Arial")
font.setPointSize(12)
self.api_amount.setFont(font)
self.api_amount.setObjectName("api_amount")
self.ItemTable = QtWidgets.QTableView(self.centralwidget)
self.ItemTable.setGeometry(QtCore.QRect(30, 270, 471, 281))
self.ItemTable.setObjectName("ItemTable")
self.dropdown_apiunit = QtWidgets.QComboBox(self.centralwidget)
self.dropdown_apiunit.setGeometry(QtCore.QRect(330, 130, 80, 26))
self.dropdown_apiunit.setObjectName("dropdown_apiunit")
self.dropdown_apiunit.addItem("")
self.dropdown_apiunit.addItem("")
self.dropdown_apiunit.addItem("")
self.dropdown_apiunit.addItem("")
self.pb_BatchRegisterLabel = QtWidgets.QPushButton(self.centralwidget)
self.pb_BatchRegisterLabel.setGeometry(QtCore.QRect(280, 570, 221, 111))
font = QtGui.QFont()
font.setFamily("Arial")
font.setPointSize(14)
self.pb_BatchRegisterLabel.setFont(font)
self.pb_BatchRegisterLabel.setObjectName("pb_BatchRegisterLabel")
self.pb_removeTableEntry = QtWidgets.QPushButton(self.centralwidget)
self.pb_removeTableEntry.setGeometry(QtCore.QRect(520, 390, 75, 23))
font = QtGui.QFont()
font.setFamily("Arial")
font.setPointSize(12)
self.pb_removeTableEntry.setFont(font)
self.pb_removeTableEntry.setObjectName("pb_removeTableEntry")
self.lineedit_projectno = QtWidgets.QLineEdit(self.centralwidget)
self.lineedit_projectno.setGeometry(QtCore.QRect(620, 50, 91, 26))
font = QtGui.QFont()
font.setFamily("Arial")
font.setPointSize(14)
font.setBold(True)
font.setWeight(75)
self.lineedit_projectno.setFont(font)
self.lineedit_projectno.setText("")
self.lineedit_projectno.setObjectName("lineedit_projectno")
self.label = QtWidgets.QLabel(self.centralwidget)
self.label.setGeometry(QtCore.QRect(720, 50, 21, 21))
font = QtGui.QFont()
font.setFamily("Arial")
font.setPointSize(26)
self.label.setFont(font)
self.label.setObjectName("label")
self.lineedit_formulationno = QtWidgets.QLineEdit(self.centralwidget)
self.lineedit_formulationno.setGeometry(QtCore.QRect(740, 50, 91, 26))
font = QtGui.QFont()
font.setFamily("Arial")
font.setPointSize(14)
font.setBold(True)
font.setWeight(75)
self.lineedit_formulationno.setFont(font)
self.lineedit_formulationno.setText("")
self.lineedit_formulationno.setObjectName("lineedit_formulationno")
self.label_2 = QtWidgets.QLabel(self.centralwidget)
self.label_2.setGeometry(QtCore.QRect(840, 50, 21, 21))
font = QtGui.QFont()
font.setFamily("Arial")
font.setPointSize(26)
self.label_2.setFont(font)
self.label_2.setObjectName("label_2")
self.lineedit_apino = QtWidgets.QLineEdit(self.centralwidget)
self.lineedit_apino.setGeometry(QtCore.QRect(860, 50, 91, 26))
font = QtGui.QFont()
font.setFamily("Arial")
font.setPointSize(14)
font.setBold(True)
font.setWeight(75)
self.lineedit_apino.setFont(font)
self.lineedit_apino.setText("")
self.lineedit_apino.setObjectName("lineedit_apino")
self.label_3 = QtWidgets.QLabel(self.centralwidget)
self.label_3.setGeometry(QtCore.QRect(960, 50, 21, 21))
font = QtGui.QFont()
font.setFamily("Arial")
font.setPointSize(26)
self.label_3.setFont(font)
self.label_3.setObjectName("label_3")
self.lineedit_batchno = QtWidgets.QLineEdit(self.centralwidget)
self.lineedit_batchno.setGeometry(QtCore.QRect(980, 50, 71, 26))
font = QtGui.QFont()
font.setFamily("Arial")
font.setPointSize(14)
font.setBold(True)
font.setWeight(75)
self.lineedit_batchno.setFont(font)
self.lineedit_batchno.setText("")
self.lineedit_batchno.setObjectName("lineedit_batchno")
self.dropdown_processtype = QtWidgets.QComboBox(self.centralwidget)
self.dropdown_processtype.setGeometry(QtCore.QRect(30, 50, 291, 31))
font = QtGui.QFont()
font.setFamily("Arial")
font.setPointSize(14)
self.dropdown_processtype.setFont(font)
self.dropdown_processtype.setObjectName("dropdown_processtype")
self.dropdown_processtype.addItem("")
self.dropdown_processtype.setItemText(0, "")
self.dropdown_processtype.addItem("")
self.dropdown_processtype.addItem("")
self.dropdown_processtype.addItem("")
self.dropdown_processtype.addItem("")
self.dropdown_processtype.addItem("")
self.dropdown_processtype.addItem("")
self.dropdown_processtype.addItem("")
self.dropdown_processtype.addItem("")
self.label_4 = QtWidgets.QLabel(self.centralwidget)
self.label_4.setGeometry(QtCore.QRect(30, 20, 141, 21))
font = QtGui.QFont()
font.setFamily("Arial")
font.setPointSize(14)
self.label_4.setFont(font)
self.label_4.setObjectName("label_4")
self.textEdit_comment = QtWidgets.QTextEdit(self.centralwidget)
self.textEdit_comment.setGeometry(QtCore.QRect(630, 300, 511, 251))
self.textEdit_comment.setObjectName("textEdit_comment")
self.label_5 = QtWidgets.QLabel(self.centralwidget)
self.label_5.setGeometry(QtCore.QRect(630, 260, 151, 21))
font = QtGui.QFont()
font.setFamily("Arial")
font.setPointSize(14)
self.label_5.setFont(font)
self.label_5.setObjectName("label_5")
self.label_6 = QtWidgets.QLabel(self.centralwidget)
self.label_6.setGeometry(QtCore.QRect(620, 20, 151, 21))
font = QtGui.QFont()
font.setFamily("Arial")
font.setPointSize(14)
self.label_6.setFont(font)
self.label_6.setObjectName("label_6")
self.PushButton_NNCnoImport = QtWidgets.QPushButton(self.centralwidget)
self.PushButton_NNCnoImport.setGeometry(QtCore.QRect(1070, 30, 91, 26))
font = QtGui.QFont()
font.setFamily("Arial")
font.setPointSize(14)
self.PushButton_NNCnoImport.setFont(font)
self.PushButton_NNCnoImport.setCursor(QtGui.QCursor(QtCore.Qt.ArrowCursor))
self.PushButton_NNCnoImport.setObjectName("PushButton_NNCnoImport")
self.pb_formulationRegister = QtWidgets.QPushButton(self.centralwidget)
self.pb_formulationRegister.setGeometry(QtCore.QRect(30, 570, 221, 111))
font = QtGui.QFont()
font.setFamily("Arial")
font.setPointSize(14)
self.pb_formulationRegister.setFont(font)
self.pb_formulationRegister.setObjectName("pb_formulationRegister")
self.TextEdit_api = QtWidgets.QTextEdit(self.centralwidget)
self.TextEdit_api.setGeometry(QtCore.QRect(420, 130, 191, 26))
self.TextEdit_api.setObjectName("TextEdit_api")
self.TextEdit_Excipient = QtWidgets.QTextEdit(self.centralwidget)
self.TextEdit_Excipient.setGeometry(QtCore.QRect(420, 170, 191, 26))
self.TextEdit_Excipient.setObjectName("TextEdit_Excipient")
self.PushButton_Scan = QtWidgets.QPushButton(self.centralwidget)
self.PushButton_Scan.setGeometry(QtCore.QRect(1070, 60, 91, 26))
font = QtGui.QFont()
font.setFamily("Arial")
font.setPointSize(14)
self.PushButton_Scan.setFont(font)
self.PushButton_Scan.setCursor(QtGui.QCursor(QtCore.Qt.ArrowCursor))
self.PushButton_Scan.setObjectName("PushButton_Scan")
self.label_7 = QtWidgets.QLabel(self.centralwidget)
self.label_7.setGeometry(QtCore.QRect(420, 100, 141, 21))
font = QtGui.QFont()
font.setFamily("Arial")
font.setPointSize(14)
self.label_7.setFont(font)
self.label_7.setObjectName("label_7")
self.lineedit_ExcipientName = QtWidgets.QLineEdit(self.centralwidget)
self.lineedit_ExcipientName.setGeometry(QtCore.QRect(30, 170, 143, 26))
self.lineedit_ExcipientName.setCompleter(self.completer)
font = QtGui.QFont()
font.setFamily("Arial")
font.setPointSize(12)
self.lineedit_ExcipientName.setFont(font)
self.lineedit_ExcipientName.setObjectName("lineedit_ExcipientName")
self.lineedit_excipientamount = QtWidgets.QLineEdit(self.centralwidget)
self.lineedit_excipientamount.setGeometry(QtCore.QRect(180, 170, 142, 26))
font = QtGui.QFont()
font.setFamily("Arial")
font.setPointSize(12)
self.lineedit_excipientamount.setFont(font)
self.lineedit_excipientamount.setObjectName("lineedit_excipientamount")
self.dropdown_excipientunit = QtWidgets.QComboBox(self.centralwidget)
self.dropdown_excipientunit.setGeometry(QtCore.QRect(330, 170, 80, 26))
self.dropdown_excipientunit.setObjectName("dropdown_excipientunit")
self.dropdown_excipientunit.addItem("")
self.dropdown_excipientunit.addItem("")
self.dropdown_excipientunit.addItem("")
self.dropdown_excipientunit.addItem("")
self.pb_excipientinsert = QtWidgets.QPushButton(self.centralwidget)
self.pb_excipientinsert.setGeometry(QtCore.QRect(630, 170, 75, 26))
font = QtGui.QFont()
font.setFamily("Arial")
font.setPointSize(12)
self.pb_excipientinsert.setFont(font)
self.pb_excipientinsert.setObjectName("pb_excipientinsert")
mainWindow.setCentralWidget(self.centralwidget)
self.menubar = QtWidgets.QMenuBar(mainWindow)
self.menubar.setGeometry(QtCore.QRect(0, 0, 1195, 21))
self.menubar.setObjectName("menubar")
mainWindow.setMenuBar(self.menubar)
self.statusbar = QtWidgets.QStatusBar(mainWindow)
self.statusbar.setObjectName("statusbar")
mainWindow.setStatusBar(self.statusbar)
self.retranslateUi(mainWindow)
QtCore.QMetaObject.connectSlotsByName(mainWindow)
mainWindow.setTabOrder(self.lineedit_api, self.api_amount)
mainWindow.setTabOrder(self.api_amount, self.dropdown_apiunit)
mainWindow.setTabOrder(self.dropdown_apiunit, self.pb_apiinsert)
mainWindow.setTabOrder(self.pb_apiinsert, self.lineedit_ExcipientName)
mainWindow.setTabOrder(self.lineedit_ExcipientName, self.lineedit_excipientamount)
mainWindow.setTabOrder(self.lineedit_excipientamount, self.dropdown_excipientunit)
mainWindow.setTabOrder(self.dropdown_excipientunit, self.pb_excipientinsert)
mainWindow.setTabOrder(self.pb_excipientinsert, self.ItemTable)
mainWindow.setTabOrder(self.ItemTable, self.textEdit_comment)
mainWindow.setTabOrder(self.textEdit_comment, self.pb_BatchRegisterLabel)
mainWindow.setTabOrder(self.pb_BatchRegisterLabel, self.lineedit_projectno)
mainWindow.setTabOrder(self.lineedit_projectno, self.lineedit_formulationno)
mainWindow.setTabOrder(self.lineedit_formulationno, self.lineedit_apino)
mainWindow.setTabOrder(self.lineedit_apino, self.lineedit_batchno)
mainWindow.setTabOrder(self.lineedit_batchno, self.dropdown_processtype)
mainWindow.setTabOrder(self.dropdown_processtype, self.pb_removeTableEntry)
def retranslateUi(self, mainWindow):
_translate = QtCore.QCoreApplication.translate
mainWindow.setWindowTitle(_translate("mainWindow", "MainWindow"))
self.lineedit_api.setText(_translate("mainWindow", "API NNCNo"))
self.pb_apiinsert.setText(_translate("mainWindow", "Insert"))
self.api_amount.setText(_translate("mainWindow", "Amount"))
self.dropdown_apiunit.setItemText(0, _translate("mainWindow", "mg"))
self.dropdown_apiunit.setItemText(1, _translate("mainWindow", "mg/tablet"))
self.dropdown_apiunit.setItemText(2, _translate("mainWindow", "% (w/w)"))
self.dropdown_apiunit.setItemText(3, _translate("mainWindow", "mg/capsule"))
self.pb_BatchRegisterLabel.setText(_translate("mainWindow", "Batch Register and Label"))
self.pb_removeTableEntry.setText(_translate("mainWindow", "Remove"))
self.label.setText(_translate("mainWindow", "-"))
self.label_2.setText(_translate("mainWindow", "-"))
self.label_3.setText(_translate("mainWindow", "-"))
self.dropdown_processtype.setItemText(1, _translate("mainWindow", "option 1"))
self.dropdown_processtype.setItemText(2, _translate("mainWindow", "option 2"))
self.dropdown_processtype.setItemText(3, _translate("mainWindow", "option 3"))
self.dropdown_processtype.setItemText(4, _translate("mainWindow", "option 4"))
self.dropdown_processtype.setItemText(5, _translate("mainWindow", "option 5"))
self.dropdown_processtype.setItemText(6, _translate("mainWindow", "option 6"))
self.dropdown_processtype.setItemText(7, _translate("mainWindow", "option 7"))
self.dropdown_processtype.setItemText(8, _translate("mainWindow", "User specify"))
self.label_4.setText(_translate("mainWindow", "Process Type"))
self.textEdit_comment.setHtml(_translate("mainWindow", "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd\">\n"
"<html><head><meta name=\"qrichtext\" content=\"1\" /><style type=\"text/css\">\n"
"p, li { white-space: pre-wrap; }\n"
"</style></head><body style=\" font-family:\'MS Shell Dlg 2\'; font-size:8.25pt; font-weight:400; font-style:normal;\">\n"
"<p style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><br /></p></body></html>"))
self.label_5.setText(_translate("mainWindow", "Comment"))
self.label_6.setText(_translate("mainWindow", "NNC No"))
self.PushButton_NNCnoImport.setText(_translate("mainWindow", "Import"))
self.pb_formulationRegister.setText(_translate("mainWindow", "Register Formulation"))
self.TextEdit_api.setHtml(_translate("mainWindow", "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd\">\n"
"<html><head><meta name=\"qrichtext\" content=\"1\" /><style type=\"text/css\">\n"
"p, li { white-space: pre-wrap; }\n"
"</style></head><body style=\" font-family:\'MS Shell Dlg 2\'; font-size:8.25pt; font-weight:400; font-style:normal;\">\n"
"<p style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><br /></p></body></html>"))
self.TextEdit_Excipient.setHtml(_translate("mainWindow", "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd\">\n"
"<html><head><meta name=\"qrichtext\" content=\"1\" /><style type=\"text/css\">\n"
"p, li { white-space: pre-wrap; }\n"
"</style></head><body style=\" font-family:\'MS Shell Dlg 2\'; font-size:8.25pt; font-weight:400; font-style:normal;\">\n"
"<p style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><br /></p></body></html>"))
self.PushButton_Scan.setText(_translate("mainWindow", "Scan"))
self.label_7.setText(_translate("mainWindow", "Comments"))
self.lineedit_ExcipientName.setText(_translate("mainWindow", "Excipient Name"))
self.lineedit_excipientamount.setText(_translate("mainWindow", "Amount"))
self.dropdown_excipientunit.setItemText(0, _translate("mainWindow", "mg"))
self.dropdown_excipientunit.setItemText(1, _translate("mainWindow", "mg/tablet"))
self.dropdown_excipientunit.setItemText(2, _translate("mainWindow", "% (w/w)"))
self.dropdown_excipientunit.setItemText(3, _translate("mainWindow", "mg/capsule"))
self.pb_excipientinsert.setText(_translate("mainWindow", "Insert"))
def __init__(self):
#upon initiation store the path to the different REST calls
self.url_standardcomponent = "http://somewhere"
#self.url_auth = " http://somwhere"
#self.username = 'username'
#self.password = 'password' #This must be changed later using Keberos-requests
#Import the standard component
tool.import_standardcomponent(self)
#Prepare the model for completer
self.model = QtGui.QStandardItemModel()
#The StandardModelItem only accepts string and not int, therefore a conversion is required
Id = [str(thing) for thing in self.SCL_Id]
IdCompound = [str(thing) for thing in self.SCL_IdCompound]
ziplist1 = list(zip(Id, IdCompound, self.SCL_Name))
ziplist2 = list(zip(Id, IdCompound, self.SCL_OtherNames))
#The idea here is to create a list with 3 columns. The 1., 2. columns being Id and IdCompounds. The 3rd comlumn is contains Name.
#Once done, the list will be append with OtherNames in the 3rd column. Reason being QCompleter can only match one column. Therefore
#Name and OtherNames have to be in 3rd column
for name in ziplist1:
row = list()
for col in name:
cell = QtGui.QStandardItem(col) #Has made sure that everything is a string
row.append(cell)
self.model.appendRow(row)
for name in ziplist2:
row = list()
for col in name:
cell = QtGui.QStandardItem(col)
row.append(cell)
self.model.appendRow(row)
#Prepare the completer
self.completer = QtWidgets.QCompleter()
self.completer.setCaseSensitivity(QtCore.Qt.CaseInsensitive)
self.completer.setCompletionColumn(2) #Will use 2nd column containing both Name and OtherNames for completion
self.completer.setModel(self.model)
#I get the described error when running the below line. Also I have a question, does bracket [QtCore.QMOdelIndex] mean that the class is provided as a list?
self.completer.activated[QtCore.QModelIndex].connect(self.onActivated)
@QtCore.pyqtSlot(QtCore.QModelIndex)
def onActivated(self, index):
_id = index.sibling(index.row(), 0).data()
_id_compound = index.sibling(index.row(), 1).data()
text = index.data()
print(_id, _id_compound, text)
if __name__ == "__main__":
import sys
app = QtWidgets.QApplication(sys.argv)
mainWindow = QtWidgets.QMainWindow()
ui = Ui_mainWindow()
ui.setupUi(mainWindow)
mainWindow.show()
sys.exit(app.exec_())
最佳答案
激活的信号是重载的,也就是说,它可以返回QString
(默认情况下,在python str
中)或QModelIndex
。所以必须通过使用completer.activated [QtCore.QModelIndex].connect(...)
来指示,获取QModelIndex你可以使用sibling方法获取兄弟,或者使用 itemFromIndex() 获取项目。方法。
from PyQt5 import QtCore, QtGui, QtWidgets
class Widget(QtWidgets.QWidget):
def __init__(self, parent=None):
super(Widget, self).__init__(parent)
Id = ["1", "2", "3", "4", "5", "6"]
IdCompound = ["a", "b", "c", "d", "e", "f"]
SCL_Name = ["p", "p", "q", "q", "r", "r"]
SCL_OtherNames = ["x", "x", "y", "y", "z", "z"]
ziplist1 = list(zip(Id, IdCompound, SCL_Name))
ziplist2 = list(zip(Id, IdCompound, SCL_OtherNames))
self.m_model = QtGui.QStandardItemModel()
for name in ziplist1 + ziplist2:
row = list()
for col in name:
cell = QtGui.QStandardItem(col)
row.append(cell)
self.m_model.appendRow(row)
self.m_completer = QtWidgets.QCompleter(
completionColumn=2, caseSensitivity=QtCore.Qt.CaseInsensitive
)
self.m_completer.setModel(self.m_model)
self.m_completer.activated[QtCore.QModelIndex].connect(self.onActivated)
self.m_lineedit = QtWidgets.QLineEdit()
self.m_lineedit.setCompleter(self.m_completer)
self.m_tableview = QtWidgets.QTableView()
self.m_tableview.setModel(self.m_model)
lay = QtWidgets.QVBoxLayout(self)
lay.addWidget(self.m_lineedit)
lay.addWidget(self.m_tableview)
@QtCore.pyqtSlot(QtCore.QModelIndex)
def onActivated(self, index):
_id = index.sibling(index.row(), 0).data()
_id_compound = index.sibling(index.row(), 1).data()
text = index.data()
print(_id, _id_compound, text)
if __name__ == "__main__":
import sys
app = QtWidgets.QApplication(sys.argv)
sc = Widget()
sc.show()
sys.exit(app.exec_())
<小时/>
您不应修改 Qt Designer 生成的类(1),因为它不是窗口小部件,而应创建另一个继承相应窗口小部件的类(2) 并使用初始类来填充它。装饰器 @pyqtSlot() 只能像小部件一样在 QObject 中工作,在您的情况下 Ui_MainWindow 则不能,因此您会观察到该错误。
考虑到解决方案是:
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'main_v01.ui'
#
# Created by: PyQt5 UI code generator 5.9.2
#
# WARNING! All changes made in this file will be lost!
from PyQt5 import QtCore, QtGui, QtWidgets
# import EBM_DB_tools as tool
class Ui_mainWindow(object):
def setupUi(self, mainWindow):
mainWindow.setObjectName("mainWindow")
mainWindow.resize(1195, 818)
mainWindow.setWindowOpacity(2.0)
mainWindow.setAutoFillBackground(False)
mainWindow.setToolButtonStyle(QtCore.Qt.ToolButtonFollowStyle)
self.centralwidget = QtWidgets.QWidget(mainWindow)
self.centralwidget.setObjectName("centralwidget")
self.lineedit_api = QtWidgets.QLineEdit(self.centralwidget)
self.lineedit_api.setGeometry(QtCore.QRect(30, 130, 143, 26))
font = QtGui.QFont()
font.setFamily("Arial")
font.setPointSize(12)
self.lineedit_api.setFont(font)
self.lineedit_api.setObjectName("lineedit_api")
self.pb_apiinsert = QtWidgets.QPushButton(self.centralwidget)
self.pb_apiinsert.setGeometry(QtCore.QRect(630, 130, 75, 26))
font = QtGui.QFont()
font.setFamily("Arial")
font.setPointSize(12)
self.pb_apiinsert.setFont(font)
self.pb_apiinsert.setAutoFillBackground(False)
self.pb_apiinsert.setObjectName("pb_apiinsert")
self.api_amount = QtWidgets.QLineEdit(self.centralwidget)
self.api_amount.setGeometry(QtCore.QRect(178, 130, 142, 26))
font = QtGui.QFont()
font.setFamily("Arial")
font.setPointSize(12)
self.api_amount.setFont(font)
self.api_amount.setObjectName("api_amount")
self.ItemTable = QtWidgets.QTableView(self.centralwidget)
self.ItemTable.setGeometry(QtCore.QRect(30, 270, 471, 281))
self.ItemTable.setObjectName("ItemTable")
self.dropdown_apiunit = QtWidgets.QComboBox(self.centralwidget)
self.dropdown_apiunit.setGeometry(QtCore.QRect(330, 130, 80, 26))
self.dropdown_apiunit.setObjectName("dropdown_apiunit")
self.dropdown_apiunit.addItem("")
self.dropdown_apiunit.addItem("")
self.dropdown_apiunit.addItem("")
self.dropdown_apiunit.addItem("")
self.pb_BatchRegisterLabel = QtWidgets.QPushButton(self.centralwidget)
self.pb_BatchRegisterLabel.setGeometry(QtCore.QRect(280, 570, 221, 111))
font = QtGui.QFont()
font.setFamily("Arial")
font.setPointSize(14)
self.pb_BatchRegisterLabel.setFont(font)
self.pb_BatchRegisterLabel.setObjectName("pb_BatchRegisterLabel")
self.pb_removeTableEntry = QtWidgets.QPushButton(self.centralwidget)
self.pb_removeTableEntry.setGeometry(QtCore.QRect(520, 390, 75, 23))
font = QtGui.QFont()
font.setFamily("Arial")
font.setPointSize(12)
self.pb_removeTableEntry.setFont(font)
self.pb_removeTableEntry.setObjectName("pb_removeTableEntry")
self.lineedit_projectno = QtWidgets.QLineEdit(self.centralwidget)
self.lineedit_projectno.setGeometry(QtCore.QRect(620, 50, 91, 26))
font = QtGui.QFont()
font.setFamily("Arial")
font.setPointSize(14)
font.setBold(True)
font.setWeight(75)
self.lineedit_projectno.setFont(font)
self.lineedit_projectno.setText("")
self.lineedit_projectno.setObjectName("lineedit_projectno")
self.label = QtWidgets.QLabel(self.centralwidget)
self.label.setGeometry(QtCore.QRect(720, 50, 21, 21))
font = QtGui.QFont()
font.setFamily("Arial")
font.setPointSize(26)
self.label.setFont(font)
self.label.setObjectName("label")
self.lineedit_formulationno = QtWidgets.QLineEdit(self.centralwidget)
self.lineedit_formulationno.setGeometry(QtCore.QRect(740, 50, 91, 26))
font = QtGui.QFont()
font.setFamily("Arial")
font.setPointSize(14)
font.setBold(True)
font.setWeight(75)
self.lineedit_formulationno.setFont(font)
self.lineedit_formulationno.setText("")
self.lineedit_formulationno.setObjectName("lineedit_formulationno")
self.label_2 = QtWidgets.QLabel(self.centralwidget)
self.label_2.setGeometry(QtCore.QRect(840, 50, 21, 21))
font = QtGui.QFont()
font.setFamily("Arial")
font.setPointSize(26)
self.label_2.setFont(font)
self.label_2.setObjectName("label_2")
self.lineedit_apino = QtWidgets.QLineEdit(self.centralwidget)
self.lineedit_apino.setGeometry(QtCore.QRect(860, 50, 91, 26))
font = QtGui.QFont()
font.setFamily("Arial")
font.setPointSize(14)
font.setBold(True)
font.setWeight(75)
self.lineedit_apino.setFont(font)
self.lineedit_apino.setText("")
self.lineedit_apino.setObjectName("lineedit_apino")
self.label_3 = QtWidgets.QLabel(self.centralwidget)
self.label_3.setGeometry(QtCore.QRect(960, 50, 21, 21))
font = QtGui.QFont()
font.setFamily("Arial")
font.setPointSize(26)
self.label_3.setFont(font)
self.label_3.setObjectName("label_3")
self.lineedit_batchno = QtWidgets.QLineEdit(self.centralwidget)
self.lineedit_batchno.setGeometry(QtCore.QRect(980, 50, 71, 26))
font = QtGui.QFont()
font.setFamily("Arial")
font.setPointSize(14)
font.setBold(True)
font.setWeight(75)
self.lineedit_batchno.setFont(font)
self.lineedit_batchno.setText("")
self.lineedit_batchno.setObjectName("lineedit_batchno")
self.dropdown_processtype = QtWidgets.QComboBox(self.centralwidget)
self.dropdown_processtype.setGeometry(QtCore.QRect(30, 50, 291, 31))
font = QtGui.QFont()
font.setFamily("Arial")
font.setPointSize(14)
self.dropdown_processtype.setFont(font)
self.dropdown_processtype.setObjectName("dropdown_processtype")
self.dropdown_processtype.addItem("")
self.dropdown_processtype.setItemText(0, "")
self.dropdown_processtype.addItem("")
self.dropdown_processtype.addItem("")
self.dropdown_processtype.addItem("")
self.dropdown_processtype.addItem("")
self.dropdown_processtype.addItem("")
self.dropdown_processtype.addItem("")
self.dropdown_processtype.addItem("")
self.dropdown_processtype.addItem("")
self.label_4 = QtWidgets.QLabel(self.centralwidget)
self.label_4.setGeometry(QtCore.QRect(30, 20, 141, 21))
font = QtGui.QFont()
font.setFamily("Arial")
font.setPointSize(14)
self.label_4.setFont(font)
self.label_4.setObjectName("label_4")
self.textEdit_comment = QtWidgets.QTextEdit(self.centralwidget)
self.textEdit_comment.setGeometry(QtCore.QRect(630, 300, 511, 251))
self.textEdit_comment.setObjectName("textEdit_comment")
self.label_5 = QtWidgets.QLabel(self.centralwidget)
self.label_5.setGeometry(QtCore.QRect(630, 260, 151, 21))
font = QtGui.QFont()
font.setFamily("Arial")
font.setPointSize(14)
self.label_5.setFont(font)
self.label_5.setObjectName("label_5")
self.label_6 = QtWidgets.QLabel(self.centralwidget)
self.label_6.setGeometry(QtCore.QRect(620, 20, 151, 21))
font = QtGui.QFont()
font.setFamily("Arial")
font.setPointSize(14)
self.label_6.setFont(font)
self.label_6.setObjectName("label_6")
self.PushButton_NNCnoImport = QtWidgets.QPushButton(self.centralwidget)
self.PushButton_NNCnoImport.setGeometry(QtCore.QRect(1070, 30, 91, 26))
font = QtGui.QFont()
font.setFamily("Arial")
font.setPointSize(14)
self.PushButton_NNCnoImport.setFont(font)
self.PushButton_NNCnoImport.setCursor(QtGui.QCursor(QtCore.Qt.ArrowCursor))
self.PushButton_NNCnoImport.setObjectName("PushButton_NNCnoImport")
self.pb_formulationRegister = QtWidgets.QPushButton(self.centralwidget)
self.pb_formulationRegister.setGeometry(QtCore.QRect(30, 570, 221, 111))
font = QtGui.QFont()
font.setFamily("Arial")
font.setPointSize(14)
self.pb_formulationRegister.setFont(font)
self.pb_formulationRegister.setObjectName("pb_formulationRegister")
self.TextEdit_api = QtWidgets.QTextEdit(self.centralwidget)
self.TextEdit_api.setGeometry(QtCore.QRect(420, 130, 191, 26))
self.TextEdit_api.setObjectName("TextEdit_api")
self.TextEdit_Excipient = QtWidgets.QTextEdit(self.centralwidget)
self.TextEdit_Excipient.setGeometry(QtCore.QRect(420, 170, 191, 26))
self.TextEdit_Excipient.setObjectName("TextEdit_Excipient")
self.PushButton_Scan = QtWidgets.QPushButton(self.centralwidget)
self.PushButton_Scan.setGeometry(QtCore.QRect(1070, 60, 91, 26))
font = QtGui.QFont()
font.setFamily("Arial")
font.setPointSize(14)
self.PushButton_Scan.setFont(font)
self.PushButton_Scan.setCursor(QtGui.QCursor(QtCore.Qt.ArrowCursor))
self.PushButton_Scan.setObjectName("PushButton_Scan")
self.label_7 = QtWidgets.QLabel(self.centralwidget)
self.label_7.setGeometry(QtCore.QRect(420, 100, 141, 21))
font = QtGui.QFont()
font.setFamily("Arial")
font.setPointSize(14)
self.label_7.setFont(font)
self.label_7.setObjectName("label_7")
self.lineedit_ExcipientName = QtWidgets.QLineEdit(self.centralwidget)
self.lineedit_ExcipientName.setGeometry(QtCore.QRect(30, 170, 143, 26))
font = QtGui.QFont()
font.setFamily("Arial")
font.setPointSize(12)
self.lineedit_ExcipientName.setFont(font)
self.lineedit_ExcipientName.setObjectName("lineedit_ExcipientName")
self.lineedit_excipientamount = QtWidgets.QLineEdit(self.centralwidget)
self.lineedit_excipientamount.setGeometry(QtCore.QRect(180, 170, 142, 26))
font = QtGui.QFont()
font.setFamily("Arial")
font.setPointSize(12)
self.lineedit_excipientamount.setFont(font)
self.lineedit_excipientamount.setObjectName("lineedit_excipientamount")
self.dropdown_excipientunit = QtWidgets.QComboBox(self.centralwidget)
self.dropdown_excipientunit.setGeometry(QtCore.QRect(330, 170, 80, 26))
self.dropdown_excipientunit.setObjectName("dropdown_excipientunit")
self.dropdown_excipientunit.addItem("")
self.dropdown_excipientunit.addItem("")
self.dropdown_excipientunit.addItem("")
self.dropdown_excipientunit.addItem("")
self.pb_excipientinsert = QtWidgets.QPushButton(self.centralwidget)
self.pb_excipientinsert.setGeometry(QtCore.QRect(630, 170, 75, 26))
font = QtGui.QFont()
font.setFamily("Arial")
font.setPointSize(12)
self.pb_excipientinsert.setFont(font)
self.pb_excipientinsert.setObjectName("pb_excipientinsert")
mainWindow.setCentralWidget(self.centralwidget)
self.menubar = QtWidgets.QMenuBar(mainWindow)
self.menubar.setGeometry(QtCore.QRect(0, 0, 1195, 21))
self.menubar.setObjectName("menubar")
mainWindow.setMenuBar(self.menubar)
self.statusbar = QtWidgets.QStatusBar(mainWindow)
self.statusbar.setObjectName("statusbar")
mainWindow.setStatusBar(self.statusbar)
self.retranslateUi(mainWindow)
QtCore.QMetaObject.connectSlotsByName(mainWindow)
mainWindow.setTabOrder(self.lineedit_api, self.api_amount)
mainWindow.setTabOrder(self.api_amount, self.dropdown_apiunit)
mainWindow.setTabOrder(self.dropdown_apiunit, self.pb_apiinsert)
mainWindow.setTabOrder(self.pb_apiinsert, self.lineedit_ExcipientName)
mainWindow.setTabOrder(self.lineedit_ExcipientName, self.lineedit_excipientamount)
mainWindow.setTabOrder(self.lineedit_excipientamount, self.dropdown_excipientunit)
mainWindow.setTabOrder(self.dropdown_excipientunit, self.pb_excipientinsert)
mainWindow.setTabOrder(self.pb_excipientinsert, self.ItemTable)
mainWindow.setTabOrder(self.ItemTable, self.textEdit_comment)
mainWindow.setTabOrder(self.textEdit_comment, self.pb_BatchRegisterLabel)
mainWindow.setTabOrder(self.pb_BatchRegisterLabel, self.lineedit_projectno)
mainWindow.setTabOrder(self.lineedit_projectno, self.lineedit_formulationno)
mainWindow.setTabOrder(self.lineedit_formulationno, self.lineedit_apino)
mainWindow.setTabOrder(self.lineedit_apino, self.lineedit_batchno)
mainWindow.setTabOrder(self.lineedit_batchno, self.dropdown_processtype)
mainWindow.setTabOrder(self.dropdown_processtype, self.pb_removeTableEntry)
def retranslateUi(self, mainWindow):
_translate = QtCore.QCoreApplication.translate
mainWindow.setWindowTitle(_translate("mainWindow", "MainWindow"))
self.lineedit_api.setText(_translate("mainWindow", "API NNCNo"))
self.pb_apiinsert.setText(_translate("mainWindow", "Insert"))
self.api_amount.setText(_translate("mainWindow", "Amount"))
self.dropdown_apiunit.setItemText(0, _translate("mainWindow", "mg"))
self.dropdown_apiunit.setItemText(1, _translate("mainWindow", "mg/tablet"))
self.dropdown_apiunit.setItemText(2, _translate("mainWindow", "% (w/w)"))
self.dropdown_apiunit.setItemText(3, _translate("mainWindow", "mg/capsule"))
self.pb_BatchRegisterLabel.setText(_translate("mainWindow", "Batch Register and Label"))
self.pb_removeTableEntry.setText(_translate("mainWindow", "Remove"))
self.label.setText(_translate("mainWindow", "-"))
self.label_2.setText(_translate("mainWindow", "-"))
self.label_3.setText(_translate("mainWindow", "-"))
self.dropdown_processtype.setItemText(1, _translate("mainWindow", "option 1"))
self.dropdown_processtype.setItemText(2, _translate("mainWindow", "option 2"))
self.dropdown_processtype.setItemText(3, _translate("mainWindow", "option 3"))
self.dropdown_processtype.setItemText(4, _translate("mainWindow", "option 4"))
self.dropdown_processtype.setItemText(5, _translate("mainWindow", "option 5"))
self.dropdown_processtype.setItemText(6, _translate("mainWindow", "option 6"))
self.dropdown_processtype.setItemText(7, _translate("mainWindow", "option 7"))
self.dropdown_processtype.setItemText(8, _translate("mainWindow", "User specify"))
self.label_4.setText(_translate("mainWindow", "Process Type"))
self.textEdit_comment.setHtml(_translate("mainWindow", "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd\">\n"
"<html><head><meta name=\"qrichtext\" content=\"1\" /><style type=\"text/css\">\n"
"p, li { white-space: pre-wrap; }\n"
"</style></head><body style=\" font-family:\'MS Shell Dlg 2\'; font-size:8.25pt; font-weight:400; font-style:normal;\">\n"
"<p style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><br /></p></body></html>"))
self.label_5.setText(_translate("mainWindow", "Comment"))
self.label_6.setText(_translate("mainWindow", "NNC No"))
self.PushButton_NNCnoImport.setText(_translate("mainWindow", "Import"))
self.pb_formulationRegister.setText(_translate("mainWindow", "Register Formulation"))
self.TextEdit_api.setHtml(_translate("mainWindow", "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd\">\n"
"<html><head><meta name=\"qrichtext\" content=\"1\" /><style type=\"text/css\">\n"
"p, li { white-space: pre-wrap; }\n"
"</style></head><body style=\" font-family:\'MS Shell Dlg 2\'; font-size:8.25pt; font-weight:400; font-style:normal;\">\n"
"<p style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><br /></p></body></html>"))
self.TextEdit_Excipient.setHtml(_translate("mainWindow", "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd\">\n"
"<html><head><meta name=\"qrichtext\" content=\"1\" /><style type=\"text/css\">\n"
"p, li { white-space: pre-wrap; }\n"
"</style></head><body style=\" font-family:\'MS Shell Dlg 2\'; font-size:8.25pt; font-weight:400; font-style:normal;\">\n"
"<p style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><br /></p></body></html>"))
self.PushButton_Scan.setText(_translate("mainWindow", "Scan"))
self.label_7.setText(_translate("mainWindow", "Comments"))
self.lineedit_ExcipientName.setText(_translate("mainWindow", "Excipient Name"))
self.lineedit_excipientamount.setText(_translate("mainWindow", "Amount"))
self.dropdown_excipientunit.setItemText(0, _translate("mainWindow", "mg"))
self.dropdown_excipientunit.setItemText(1, _translate("mainWindow", "mg/tablet"))
self.dropdown_excipientunit.setItemText(2, _translate("mainWindow", "% (w/w)"))
self.dropdown_excipientunit.setItemText(3, _translate("mainWindow", "mg/capsule"))
self.pb_excipientinsert.setText(_translate("mainWindow", "Insert"))
class MainWindow(QtWidgets.QMainWindow, Ui_mainWindow):
def __init__(self):
super(MainWindow, self).__init__()
self.setupUi(self)
#upon initiation store the path to the different REST calls
self.url_standardcomponent = "http://somewhere"
#self.url_auth = " http://somwhere"
#self.username = 'username'
#self.password = 'password' #This must be changed later using Keberos-requests
#Import the standard component
# tool.import_standardcomponent(self)
self.SCL_Id = ["aaa", "bbb", "ccc"]
self.SCL_IdCompound = ["xxx", "yyy", "zzz"]
self.SCL_Name = ["111", "222", "333"]
self.SCL_OtherNames = ["PPP", "QQQ", "RRR"]
#Prepare the model for completer
self.model = QtGui.QStandardItemModel()
#The StandardModelItem only accepts string and not int, therefore a conversion is required
Id = [str(thing) for thing in self.SCL_Id]
IdCompound = [str(thing) for thing in self.SCL_IdCompound]
ziplist1 = list(zip(Id, IdCompound, self.SCL_Name))
ziplist2 = list(zip(Id, IdCompound, self.SCL_OtherNames))
#The idea here is to create a list with 3 columns. The 1., 2. columns being Id and IdCompounds. The 3rd comlumn is contains Name.
#Once done, the list will be append with OtherNames in the 3rd column. Reason being QCompleter can only match one column. Therefore
#Name and OtherNames have to be in 3rd column
for name in ziplist1:
row = list()
for col in name:
cell = QtGui.QStandardItem(col) #Has made sure that everything is a string
row.append(cell)
self.model.appendRow(row)
for name in ziplist2:
row = list()
for col in name:
cell = QtGui.QStandardItem(col)
row.append(cell)
self.model.appendRow(row)
#Prepare the completer
self.completer = QtWidgets.QCompleter()
self.completer.setCaseSensitivity(QtCore.Qt.CaseInsensitive)
self.completer.setCompletionColumn(2) #Will use 2nd column containing both Name and OtherNames for completion
self.completer.setModel(self.model)
#I get the described error when running the below line. Also I have a question, does bracket [QtCore.QMOdelIndex] mean that the class is provided as a list?
self.completer.activated[QtCore.QModelIndex].connect(self.onActivated)
self.lineedit_ExcipientName.setCompleter(self.completer)
@QtCore.pyqtSlot(QtCore.QModelIndex)
def onActivated(self, index):
_id = index.sibling(index.row(), 0).data()
_id_compound = index.sibling(index.row(), 1).data()
text = index.data()
print(_id, _id_compound, text)
if __name__ == "__main__":
import sys
app = QtWidgets.QApplication(sys.argv)
w = MainWindow()
w.show()
sys.exit(app.exec_())
<小时/>
<子>(1) Using the Generated Code
<子>(2) https://stackoverflow.com/a/46545116/6622587
关于python - 在 QCompleter 激活调用时查找 QStandardItemModel 的索引,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56887734/
为了让我的代码几乎完全用 Jquery 编写,我想用 Jquery 重写 AJAX 调用。 这是从网页到 Tomcat servlet 的调用。 我目前情况的类似代码: var http = new
我想使用 JNI 从 Java 调用 C 函数。在 C 函数中,我想创建一个 JVM 并调用一些 Java 对象。当我尝试创建 JVM 时,JNI_CreateJavaVM 返回 -1。 所以,我想知
环顾四周,我发现从 HTML 调用 Javascript 函数的最佳方法是将函数本身放在 HTML 中,而不是外部 Javascript 文件。所以我一直在网上四处寻找,找到了一些简短的教程,我可以根
我有这个组件: import {Component} from 'angular2/core'; import {UserServices} from '../services/UserService
我正在尝试用 C 实现一个简单的 OpenSSL 客户端/服务器模型,并且对 BIO_* 调用的使用感到好奇,与原始 SSL_* 调用相比,它允许一些不错的功能。 我对此比较陌生,所以我可能会完全错误
我正在处理有关异步调用的难题: 一个 JQuery 函数在用户点击时执行,然后调用一个 php 文件来检查用户输入是否与数据库中已有的信息重叠。如果是这样,则应提示用户确认是否要继续或取消,如果他单击
我有以下类(class)。 public Task { public static Task getInstance(String taskName) { return new
嘿,我正在构建一个小游戏,我正在通过制作一个数字 vector 来创建关卡,该数字 vector 通过枚举与 1-4 种颜色相关联。问题是循环(在 Simon::loadChallenge 中)我将颜
我有一个java spring boot api(数据接收器),客户端调用它来保存一些数据。一旦我完成了数据的持久化,我想进行另一个 api 调用(应该处理持久化的数据 - 数据聚合器),它应该自行异
首先,这涉及桌面应用程序而不是 ASP .Net 应用程序。 我已经为我的项目添加了一个 Web 引用,并构建了各种数据对象,例如 PayerInfo、Address 和 CreditCard。但问题
我如何告诉 FAKE 编译 .fs文件使用 fsc ? 解释如何传递参数的奖励积分,如 -a和 -target:dll . 编辑:我应该澄清一下,我正在尝试在没有 MSBuild/xbuild/.sl
我使用下划线模板配置了一个简单的主干模型和 View 。两个单独的 API 使用完全相同的配置。 API 1 按预期工作。 要重现该问题,请注释掉 API 1 的 URL,并取消注释 API 2 的
我不确定什么是更好的做法或更现实的做法。我希望从头开始创建目录系统,但不确定最佳方法是什么。 我想我在需要显示信息时使用对象,例如 info.php?id=100。有这样的代码用于显示 Game.cl
from datetime import timedelta class A: def __abs__(self): return -self class B1(A):
我在操作此生命游戏示例代码中的数组时遇到问题。 情况: “生命游戏”是约翰·康威发明的一种细胞自动化技术。它由一个细胞网格组成,这些细胞可以根据数学规则生存/死亡/繁殖。该网格中的活细胞和死细胞通过
如果我像这样调用 read() 来读取文件: unsigned char buf[512]; memset(buf, 0, sizeof(unsigned char) * 512); int fd;
我用 C 编写了一个简单的服务器,并希望调用它的功能与调用其他 C 守护程序的功能相同(例如使用 ./ftpd start 调用它并使用 ./ftpd stop 关闭该实例)。显然我遇到的问题是我不知
在 dos 中,当我粘贴此命令时它会起作用: "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" https://google.
在 dos 中,当我粘贴此命令时它会起作用: "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" https://google.
我希望能够从 cmd 在我的 Windows 10 计算机上调用 python3。 我已重新安装 Python3.7 以确保选择“添加到路径”选项,但仍无法调用 python3 并使 CMD 启动 P
我是一名优秀的程序员,十分优秀!