事实证明,我在 PyQT5 中为 Qtreewidget 发出信号是一个问题。当您单击“增加”时,您需要增加 QTreeWidget 的大小,并在再次单击时减少 QTreeWidget 的大小(就像 Excel 中的过滤器),如下所示
代码:
self.tree_countries.setGeometry(QRect(1050, 100, 200, 250))
self.tree_countries.setHeaderHidden(True)
self.tree_countries.setStyleSheet("QTreeWidget {\n"
"border: 1px solid #3b3838;\n"
"font: 57 12pt \"Google Sans Medium\";\n"
"color: white;\n"
"background-color: #3b3838\n"
"}\n")
sql = filter_sql()
parent = QTreeWidgetItem(self.tree_countries)
parent.setText(0, "Страна")
parent.setFlags(parent.flags() | Qt.ItemIsTristate | Qt.ItemIsUserCheckable)
for country in sql.all_countries():
country = str(country)
child = QTreeWidgetItem(parent)
child.setFlags(child.flags() | Qt.ItemIsUserCheckable)
child.setText(0, country[2:-3])
child.setCheckState(0, Qt.Unchecked)
self.tree_countries.show()
守候你守候我
相关分类