我正在使用USB条形码扫描器来设置Qt
我的问题是,我想动态地用下一个扫描的
我无法弄清楚哪个
我想知道在下一个条形码被扫描之前,是否有一种方法可以删除文本框中之前的字符串?(不使文本字段在一段时间内为空)。
谢谢。
PS-使用Python3.5.2和Ubuntu 16.04上的pyQT4。
lineEdit
字段的文本,该文本随后用于GUI的其他功能(具体而言,该文本是用户当前测量的样品名称,并将稍后保存为文件名)。我的问题是,我想动态地用下一个扫描的
barcode
覆盖当前lineEdit
字段中的文本,无需用户手动删除当前文本即可进行扫描。因为我只是使用扫描仪作为键盘仿真器,而不是从其中正确读取串行信息,所以用户必须在扫描之前单击文本字段。我无法弄清楚哪个
lineEdit
连接操作允许以下操作:from PyQt4 import QtGui
# add widgets etc
# ...........
# lineEdit part
self.mylineEdit = QtGui.QLineEdit()
#initialise to empty string on start up
self.mylineEdit.setText(' ')
#barcode scans here and then a returnPressed is registered
#connect to a function
self.mylineEdit.returnPressed.connect(self.set_sample_name) #here is where I want to delete the previous entry without backspacing by hand
#set the sample name variable
def set_sample_name(self):
self.sample_name = self.mylindEdit.text()
我想知道在下一个条形码被扫描之前,是否有一种方法可以删除文本框中之前的字符串?(不使文本字段在一段时间内为空)。
谢谢。
PS-使用Python3.5.2和Ubuntu 16.04上的pyQT4。