Python 如何将箭头移动到qtreewidget中的下一列
在pyqt5中,使用qtreewidget,我试图移动下一个标题下的箭头。这可能吗?我想在第一列中添加缩略图,并在第二列中添加箭头 这就是我现在拥有的 这是当我移动所有东西时得到的结果,箭头停留在标题0下 我想要的模型 我试过的一个简单的例子Python 如何将箭头移动到qtreewidget中的下一列,python,pyqt,pyqt5,pyside2,qtreewidget,Python,Pyqt,Pyqt5,Pyside2,Qtreewidget,在pyqt5中,使用qtreewidget,我试图移动下一个标题下的箭头。这可能吗?我想在第一列中添加缩略图,并在第二列中添加箭头 这就是我现在拥有的 这是当我移动所有东西时得到的结果,箭头停留在标题0下 我想要的模型 我试过的一个简单的例子 import sys from PyQt5.QtWidgets import (QVBoxLayout, QDialog, QTreeWidget, QApplication, QTreeWidgetItem) class QuickExample(Q
import sys
from PyQt5.QtWidgets import (QVBoxLayout, QDialog, QTreeWidget, QApplication, QTreeWidgetItem)
class QuickExample(QDialog):
def __init__(self, parent=None):
super(QuickExample, self).__init__(parent)
layout = QVBoxLayout()
tree = QTreeWidget()
tree.setHeaderLabels(["0", "1"])
parent = QTreeWidgetItem()
parent.setText(1, "parent")
child = QTreeWidgetItem(parent)
child.setText(1, "child")
tree.addTopLevelItem(parent)
layout.addWidget(tree)
self.setLayout(layout)
if __name__ == '__main__':
app = QApplication(sys.argv)
example = QuickExample()
example.show()
sys.exit(app.exec_())
最后,我在第一列中设置了项目,并与第二列进行了交换。e、 g
import sys
from PyQt5.QtWidgets import (QVBoxLayout, QDialog, QTreeWidget,
QApplication, QTreeWidgetItem)
class QuickExample(QDialog):
def __init__(self, parent=None):
super(QuickExample, self).__init__(parent)
layout = QVBoxLayout()
tree = QTreeWidget()
tree.setHeaderLabels(["Name", "Thumbnail"])
# swapping the first with the second
tree.header().swapSections(1, 0)
parent = QTreeWidgetItem()
parent.setText(0, "parent")
child = QTreeWidgetItem(parent)
child.setText(0, "child")
tree.addTopLevelItem(parent)
layout.addWidget(tree)
self.setLayout(layout)
if __name__ == '__main__':
app = QApplication(sys.argv)
example = QuickExample()
example.show()
sys.exit(app.exec_())
现在我可以在新的第一列添加缩略图。如何移动所有元素?请提供一份到目前为止您所做工作的详细说明。还有,原因是什么?移动树后,你将在第一栏显示什么?有帮助吗?@Heike是的,谢谢!树,头,交换部分1,0是我需要的。