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. Qt Designer Property Sheet plugin crashing
Forum Updated to NodeBB v4.3 + New Features

Qt Designer Property Sheet plugin crashing

Scheduled Pinned Locked Moved Unsolved Qt for Python
1 Posts 1 Posters 455 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.
  • I Offline
    I Offline
    ivany4
    wrote on last edited by
    #1

    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?

    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