Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for Python
  4. [Bug] Using QTreeWidget.setItemWidget stops PySide window from loading + and crashes programs that use it

[Bug] Using QTreeWidget.setItemWidget stops PySide window from loading + and crashes programs that use it

Scheduled Pinned Locked Moved Unsolved Qt for Python
1 Posts 1 Posters 505 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    PeterH92
    wrote on last edited by PeterH92
    #1

    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_())
    
    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved