[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"><<a href="mailto:phil@riverbankcomputing.com" \
target="_blank">phil@riverbankcomputing.com</a>></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 \
<<a href="mailto:christop.probst@gmail.com">christop.probst@gmail.com</a>> \
wrote:<br> ><br>
> Hi,<br>
><br>
> I am starting to feel a lot of love for PyQt. I am inquiring about how the Qt \
Property system translates into PyQt<br> ><br>
> The documentation states:<br>
> "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."<br> ><br>
> Does this mean I can't write label.setProperty("text" , \
"HelloWorld")? I am not exactly sure what this means.<br> ><br>
> I have tried this for instance and it works great:<br>
><br>
> for i in range(0, propertyCount):<br>
> metaProperty = metaObject.property(i)<br>
> typeName = metaProperty.typeName()<br>
> propertyName = metaProperty.name()<br>
> value = object.property(metaProperty.<wbr>name())<br>
> print("propertyName: " + propertyName + ", value: \
" + str(value) + ", type: " + typeName)<br> ><br>
> 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't use Qt properties as it \
they were Python properties. In other words you cannot do...<br> <br>
label.text = "HelloWorld"<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