Houdini crash when a QComboBox is inserted inside a QtreeWidget

   1859   2   1
User Avatar
Member
19 posts
Joined: Nov. 2018
Offline
Hello!

I am trying to create a Qt shelf tool for Houdini. This requires a QtreeWidget with 2 columns, the first showing just some text and the second containing a dropdown menu. Below is an image illustrating this:



The result above is what I am aiming at, and is exactly what I get when I execute my code in an standalone python shell or inside other DCC apps. Whenever I try to execute this code inside Houdini though (e.g. in a hython shell, from a shelf tool, from the python source window), Houdini crashes with the following messages:

Fatal error: Segmentation fault (sent by pid 0)
Crash log saved to /tmp/houdini_temp/crash.untitled.sgatto_31294_log.txt
Warning: Missing charsets in String to FontSet conversion

Below the code I am executing:
from PySide2 import QtCore, QtWidgets
            
class MyWidget(QtWidgets.QMainWindow):

    def __init__(self, parent=None, controller=None):
        super(MyWidget, self).__init__(parent)
        
        tree = QtWidgets.QTreeWidget()
        tree.setColumnCount(2)
        tree.headerItem().setText(0, "Column 1")
        tree.headerItem().setText(1, "Column 2")
        
        cell = QtWidgets.QComboBox()
        cell.addItems(['a','b','c'])
        
        item = QtWidgets.QTreeWidgetItem(tree)
        tree.setItemWidget(item, 1, cell)        

        self.setCentralWidget(tree)     


win = MyWidget()
win.show()

Commenting
tree.setItemWidget(item, 1, cell)
is enough to make the snippet work inside Houdini, so the problem is clearly with the insertion of a ComboBox inside a QTreeWidgetItem.

Does anybody have any idea of why this is happening? Is this a bug?
Any suggestions on alternative ways to make this work would be greatly appreciated.



P.S. I already tried passing hou.qt.mainWindow() and hou.ui.mainQtWindow() as parent to MyWidget, and neither made any difference.


Thanks!
Edited by stefa-no - April 26, 2019 07:38:03

Attachments:
widget.png (3.2 KB)

User Avatar
Member
19 posts
Joined: Nov. 2018
Offline
I would also like to add that if do no wrap the code inside a class and execute inside a Houdini's python shell, it works.
Here is the snippet to test it:

tree = QtWidgets.QTreeWidget()
tree.setColumnCount(2)
tree.headerItem().setText(0, "Column 1")
tree.headerItem().setText(1, "Column 2")
item = QtWidgets.QTreeWidgetItem(tree)
cell = QtWidgets.QComboBox()
cell.addItems(['a','b','c'])
tree.setItemWidget(item, 1, cell)
tree.show()

So adding a QComboBox to QTreeWidget is generally ok inside Houdini.
User Avatar
Member
19 posts
Joined: Nov. 2018
Offline
Ok I finally found the problem. To make the code work it's enough to change
cell = QtWidgets.QComboBox()
to
cell = QtWidgets.QComboBox(parent=self)
or
cell = QtWidgets.QComboBox(parent=tree)

I still don't understand why it fails only inside Houdini and only when it is inside a class, but at least I'll leave the answer here if anybody will ever face a similar problem.
  • Quick Links