[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pykde
Subject:    [PyQt] Designer formEditor.propertyEditor().propertyChanged QVariant issue/crash
From:       Maurizio Berti <maurizio.berti () gmail ! com>
Date:       2018-02-12 18:19:44
Message-ID: CAPn+-XTMdMh7ngOTi64hq3ty_9vuo4jQYD+b=sMt+E7Qx_U9nQ () mail ! gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


As far as I know there is no straight way to access the QtDesigner
propertyEditor, so I've been using some "dirty" workaround to access the
propertyChanged signal for custom properties.
When the custom widget is initialized, I set the formEditor as attribute of
the plugin class:

    def initialize(self, formEditor):
        if self.initialized:
            return
        self.formEditor = formEditor

Then, in the createWidget() method I can access the propertyEditor and its
propertyChanged signal:

    def createWidget(self, parent):
        widget = TestWidget(parent)
        if self.formEditor.propertyEditor():

self.formEditor.propertyEditor().propertyChanged.connect(self.propertyChanged)

If I use "common" property types, such as QColor, QAlignment, or any kind
of QFlag, everything works fine. Unfortunally, it seems that QEnums have
issues with the python conversion, resulting in a "TypeError: unable to
convert a C++ 'QVariant' instance to a Python object" in both PyQt4 and
PyQt5. While Qt4 just seems to ignore the error, this results in a crash of
Designer under Qt5.
As I can understand, there is no way to avoid this behavior, since the
signal cannot be overloaded, and I sincerely doubt that this issue depends
on the way I access the formEditor/propertyEditor.

Tested under PyQt 4.12 and 5.7.1.

Thanks,
Maurizio

-- 
È difficile avere una convinzione precisa quando si parla delle ragioni del
cuore. - "Sostiene Pereira", Antonio Tabucchi
http://www.jidesk.net

[Attachment #5 (text/html)]

<div dir="ltr"><div>As far as I know there is no straight way to access the \
QtDesigner propertyEditor, so I&#39;ve been using some &quot;dirty&quot; workaround \
to access the propertyChanged signal for custom properties.<br></div><div>When the \
custom widget is initialized, I set the formEditor as attribute of the plugin \
class:</div><div><br></div><div><div>      def initialize(self, \
formEditor):</div><div>            if self.initialized:</div><div>                  \
return</div><div>            self.formEditor = \
formEditor</div><div><br></div><div>Then, in the createWidget() method I can access \
the propertyEditor and its propertyChanged signal:</div><div><br></div><div><div>     \
def createWidget(self, parent):</div><div>            widget = \
TestWidget(parent)</div><div>            if \
self.formEditor.propertyEditor():<br></div><div>                  \
self.formEditor.propertyEditor().propertyChanged.connect(self.propertyChanged)</div></div><div><br></div><div>If \
I use &quot;common&quot; property types, such as QColor, QAlignment, or any kind of \
QFlag, everything works fine. Unfortunally, it seems that QEnums have issues with the \
python conversion, resulting in a &quot;TypeError: unable to convert a C++ \
&#39;QVariant&#39; instance to a Python object&quot; in both PyQt4 and PyQt5. While \
Qt4 just seems to ignore the error, this results in a crash of Designer under \
Qt5.</div><div>As I can understand, there is no way to avoid this behavior, since the \
signal cannot be overloaded, and I sincerely doubt that this issue depends on the way \
I access the formEditor/propertyEditor.</div><div><br></div><div>Tested under PyQt \
4.12 and 5.7.1.</div><div><br>Thanks,</div><div>Maurizio</div><div><br></div>-- \
<br><div class="gmail-m_-5847619322246459414gmail_signature">È difficile avere una \
convinzione precisa quando si parla delle ragioni del cuore. - &quot;Sostiene \
Pereira&quot;, Antonio Tabucchi<br><a href="http://www.jidesk.net" \
target="_blank">http://www.jidesk.net</a></div> </div></div>


[Attachment #6 (text/plain)]

_______________________________________________
PyQt mailing list    PyQt@riverbankcomputing.com
https://www.riverbankcomputing.com/mailman/listinfo/pyqt

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic