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

List:       pykde
Subject:    Re: [PyQt] Qt Property System
From:       Christopher Probst <christop.probst () gmail ! com>
Date:       2017-06-15 15:51:02
Message-ID: CABhWjnrU6B3gvC=_ZHuArZ_Te3UTMiEjBxxpbvnuo8th=RNh4A () mail ! gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


Thank you for answering my question.

On Thu, Jun 15, 2017 at 11:47 AM, Phil Thompson <phil@riverbankcomputing.com
> wrote:

> On 15 Jun 2017, at 4:30 pm, Christopher Probst <christop.probst@gmail.com>
> wrote:
> >
> > Hi,
> >
> > I am starting to feel a lot of love for PyQt. I am inquiring about how
> the Qt Property system translates into PyQt
> >
> > The documentation states:
> > "PyQt5 does not support the setting and getting of Qt properties as if
> they were normal instance attributes. This is because the name of a
> property often conflicts with the name of the property's getter method."
> >
> > Does this mean I can't write label.setProperty("text" , "HelloWorld")? I
> am not exactly sure what this means.
> >
> > I have tried this for instance and it works great:
> >
> > for i in range(0, propertyCount):
> >         metaProperty = metaObject.property(i)
> >         typeName = metaProperty.typeName()
> >         propertyName = metaProperty.name()
> >         value = object.property(metaProperty.name())
> >         print("propertyName: " + propertyName + ", value: " + str(value)
> + ", type: " + typeName)
> >
> > Do we use the Qt Property system in PyQt?
>
> You can use Qt properties from Python as you can from C++ as your code
> above shows.
>
> The documentation is trying to point out that you can't use Qt properties
> as it they were Python properties. In other words you cannot do...
>
>     label.text = "HelloWorld"
>
> However you can use pyqtProperty to define properties that behave as both
> Python and Qt properties at the same time.
>
> Phil

[Attachment #5 (text/html)]

<div dir="ltr">Thank you for answering my question.</div><div \
class="gmail_extra"><br><div class="gmail_quote">On Thu, Jun 15, 2017 at 11:47 AM, \
Phil Thompson <span dir="ltr">&lt;<a href="mailto:phil@riverbankcomputing.com" \
target="_blank">phil@riverbankcomputing.com</a>&gt;</span> wrote:<br><blockquote \
class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc \
solid;padding-left:1ex"><span class="">On 15 Jun 2017, at 4:30 pm, Christopher Probst \
&lt;<a href="mailto:christop.probst@gmail.com">christop.probst@gmail.com</a>&gt; \
wrote:<br> &gt;<br>
&gt; Hi,<br>
&gt;<br>
&gt; I am starting to feel a lot of love for PyQt. I am inquiring about how the Qt \
Property system translates into PyQt<br> &gt;<br>
&gt; The documentation states:<br>
&gt; &quot;PyQt5 does not support the setting and getting of Qt properties as if they \
were normal instance attributes. This is because the name of a property often \
conflicts with the name of the property's getter method.&quot;<br> &gt;<br>
&gt; Does this mean I can&#39;t write label.setProperty(&quot;text&quot; , \
&quot;HelloWorld&quot;)? I am not exactly sure what this means.<br> &gt;<br>
&gt; I have tried this for instance and it works great:<br>
&gt;<br>
&gt; for i in range(0, propertyCount):<br>
&gt;              metaProperty = metaObject.property(i)<br>
&gt;              typeName = metaProperty.typeName()<br>
&gt;              propertyName = metaProperty.name()<br>
&gt;              value = object.property(metaProperty.<wbr>name())<br>
&gt;              print(&quot;propertyName: &quot; + propertyName + &quot;, value: \
&quot; + str(value) + &quot;, type: &quot; + typeName)<br> &gt;<br>
&gt; Do we use the Qt Property system in PyQt?<br>
<br>
</span>You can use Qt properties from Python as you can from C++ as your code above \
shows.<br> <br>
The documentation is trying to point out that you can&#39;t use Qt properties as it \
they were Python properties. In other words you cannot do...<br> <br>
      label.text = &quot;HelloWorld&quot;<br>
<br>
However you can use pyqtProperty to define properties that behave as both Python and \
Qt properties at the same time.<br> <span class="HOEnZb"><font color="#888888"><br>
Phil</font></span></blockquote></div><br></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