[PyQt] QDesignerPropertySheetExtension property?
Phil Thompson
phil at riverbankcomputing.com
Sat Dec 23 15:30:53 GMT 2017
On 17 Dec 2017, at 5:10 pm, Maurizio Berti <maurizio.berti at gmail.com> wrote:
>
> Hello,
> I'm writing a custom widget with a plugin for Designer in PyQt 5.7.
> What I wanted to do is to enable/disable certain properties (almost like the "checked" property for QPushButton, which is disabled if "checkable" is not checked). Since I wasn't able to find a way to obtain this, I tried another approach, by using QDesignerPropertySheetExtension's setVisible.
> My implementation connects the formEditor.propertyEditor().propertyChanged signal to a custom slot. In the slot I access the extension like this:
>
> propertySheet = self.manager.extension(widget, 'org.qt-project.Qt.Designer.PropertySheet')
> propertySheet = sip.cast(propertySheet, QtDesigner.QPyDesignerPropertySheetExtension)
This is certainly wrong as only PyQt knows about QPyDesignerPropertySheetExtension and so Designer couldn't have created an instance of it.
> index = propertySheet.indexOf('showMSecsTrailingZeros')
> QtDesigner.QPyDesignerPropertySheetExtension.setProperty(propertySheet, index, False)
> propertySheet.setVisible(index, False)
>
>
> Unfortunally, it seems that there's a problem in the pyqt implementation, since property() and setProperty() do not behave as described in the documentation (accepting the index argument), and the setVisible() function does nothing at all.
> As further confirmation of this, if I look in the help for QDesignerPropertySheetExtension.property(), the description is the same as any other QObject: property(self, str) -> any. I can see the same in PyQt 5.9 on windows.
>
> I'd like to know if I'm doing something wrong (I'm pretty new to writing custom widgets) or if there is actually a bug.
There are probably PyQt bugs as well. I doubt if the Designer stuff has ever been used beyond the widget plugins.
Phil
More information about the PyQt
mailing list