Qt Designer Property Sheet plugin crashing



  • Hi,

    I am trying to implement a Property Sheet extension via PyQt plugin. (Qt 5.12.1, PyQt 5.12, SIP 4.19.14)

    It consistently crashes because PyQt fails to understand internal format sent by Qt Designer:
    TypeError: unable to convert a C++ 'qdesigner_internal::PropertySheetStringValue' instance to a Python object

    In my case, I am trying to mimic similar behavior of the standard property sheet, where it shows all the properties of a given class by inspecting meta objects. The crash happens after Qt Designer calls "property()" method for "toolTip" property specifically, and tries to convert the value into PropertySheetStringValue and send it back to the extension via "setProperty()". Here's the code example

    import typing
    from PyQt5 import QtGui, QtDesigner, QtCore, QtWidgets
    
    
    class MyPropertySheetExtension(QtDesigner.QPyDesignerPropertySheetExtension):
    
        def __init__(self, widget: QtWidgets.QWidget, parent: QtCore.QObject):
            super(MyPropertySheetExtension, self).__init__(parent)
            self._widget = widget
    
        def property(self, index: int) -> QtCore.QVariant:
            prop = self._widget.metaObject().property(index)
            val = prop.read(self._widget)
            return QtCore.QVariant(val)
      
         # <====== Crash before calling this method with PropertySheetStringValue passed as a value)
        def setProperty(self, index: int, value: typing.Any):
            name = self.propertyName(index)
            self._widget.setProperty(name, value)
    
        def count(self) -> int:
            return self._widget.metaObject().propertyCount()
    
        def indexOf(self, name: str) -> int:
            return  self._widget.metaObject().indexOfProperty(name)
    
        def propertyGroup(self, index: int) -> str:
            return 'My Group'
    
        def propertyName(self, index: int) -> str:
            return self._widget.metaObject().property(index).name()
    
        def reset(self, index: int) -> bool:
            return self._widget.metaObject().property(index).reset(self._widget)
    
        # Rest of the methods (not important)
        ...
    

    Does anyone have an idea if this is intended behavior and why it happens specifically on toolTip and not other string properties?


Log in to reply