通过从 QlistWidget 中选择的项目更新 QLineEdit,根据我的意愿更新第一个框。但是第二个文本框和第三个文本框,没有被所选项目更新。如果我们为第二个文本框第一个文本框和第二个文本框更新选择项目。而对于第三个,没有反应?如何解决
文件:鼠标点击.py
import sys
from mouseclick_source import *
textbox1_item = ["Red", "Green", "Blue", "Brown", "White", "Black", "Grey",
"Dark Red", "Dark Green", "Dark Blue"]
textbox2_item = ["Gold", "Silver", "Bronze", "Copper", "Iron", "Aluminium",
"Taitanium"]
textbox3_item = ["Indian Ocean", "Arabian Sea", "Bay of Bengal", "Black Sea",
"Pacific Ocean"]
class Mclick_sample_main(QWidget):
def __init__(self):
super().__init__()
self.setWindowTitle("Mouse click Samples")
self.textbox1 = QLineEdit()
self.textbox2 = QLineEdit()
self.textbox3 = QLineEdit()
self.listbox1 = QListWidget()
self.listbox2 = QListWidget()
self.textbox1.setObjectName("textbox1")
self.textbox2.setObjectName("textbox2")
self.textbox3.setObjectName("textbox3")
self.listbox1.setObjectName("listbox1")
self.listbox2.setObjectName("listbox2")
vbox = QVBoxLayout(self)
vbox.addWidget(self.textbox1)
vbox.addWidget(self.textbox2)
vbox.addWidget(self.textbox3)
vbox.addWidget(self.listbox1)
QApplication.instance().focusChanged.connect(self.on_focusChanged)
def on_focusChanged(self):
fwidget = QApplication.focusWidget()
if fwidget is not None:
if fwidget.objectName() == "textbox1":
self.listbox1.clear()
self.listbox1.addItems(textbox1_item)
self.getdetails_1 = Sourcefile(self.textbox1, self.listbox1, self.listbox2)
#self.textbox1.textChanged.connect(self.getdetails_1.func_textbox_textchanged)
self.listbox1.itemClicked.connect(self.getdetails_1.listbox_clicked)
return True
BIG阳
相关分类