[Bug] Using QTreeWidget.setItemWidget stops PySide window from loading + and crashes programs that use it
PeterH92 last edited by PeterH92
I'm designing a UI that should work in both PySide and PySide2, and I've found a big flaw in that it's impossible to set a QTreeWidgetItem to use a widget in PySide. I'm needing a way to have an editable multi line cell, and this seems to be the main way of doing it. If the line exists, the window fails to load, and gives no reason why.
I tried it in Nuke 9 (PySide 1.0.9) and Nuke 10 (PySide 1.2.2), and it literally crashes the whole program, I've been using 1.2.4 outside of it though.
Here's some example code with the bug:
import sys from PySide import QtGui, QtCore class MainWindow(QtGui.QMainWindow): def __init__(self, parent=None, **kwargs): super(MainWindow, self).__init__(parent, **kwargs) #Add tree widget to window tree = QtGui.QTreeWidget() tree.setHeaderItem(QtGui.QTreeWidgetItem(['col1', 'col2'])) self.setCentralWidget(tree) #Create items topLevelButton = QtGui.QPushButton('button') topLevelItem = QtGui.QTreeWidgetItem(['test button', 'line edit']) topLevelItem.setFlags(topLevelItem.flags() | QtCore.Qt.ItemIsEditable) #Add items to tree widget tree.addTopLevelItem(topLevelItem) tree.setItemWidget(topLevelItem, 0, topLevelButton) #the window will not load if this line is not commented out if __name__ == '__main__': app = QtGui.QApplication(sys.argv) window = MainWindow() app.setActiveWindow(window) window.show() sys.exit(app.exec_())