<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<p>I am not sure if I am understanding this question correctly but
you seem to asking how to make a Class Property that you can
access like a property</p>
<pre>@property
def Item(self):
return self.InternalRef
@Item.setter
def Item(self, Value)
self.InternalRef = Value<span class="hljs-function" style="box-sizing: border-box; color: rgb(42, 42, 42); font-family: "Fira Mono", monospace; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: pre-wrap; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;">
That works and allows you to reference the variable like it was a normal class property? Further this is fairly well documented which is why I do not understand what you are attempting to ask with this question. Could you please clarify perhaps using an example of what you are driving at.
</span></pre>
<p>That works and allows you to reference the variable like it was a
normal class property? Further this is fairly well documented
which is why I do not understand the what you are attempting to
ask with this question.</p>
<pre>
<span class="hljs-function" style="box-sizing: border-box; color: rgb(42, 42, 42); font-family: "Fira Mono", monospace; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: pre-wrap; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;"></span></pre>
<div class="moz-cite-prefix">On 10/18/2020 8:22 PM, Maurizio Berti
wrote:<br>
</div>
<blockquote type="cite"
cite="mid:CAPn+-XQH-UC_=VAjX-YZMfyDOnUu9QJuMzuMJ6uX2OsHq-ArMA@mail.gmail.com">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<div dir="ltr">We all know that we can create custom QObject
properties using the `pyqtProperty` function/decorator.
<div><br>
</div>
<div>As far as I know, though, there is a small drawback: those
properties do not behave "exactly" like other QObject
properties: the small (but somehow code-wise significant)
difference is that PyQt created properties are accessible as
python properties (<font face="monospace">self.somePyQtProperty</font>)
and not like other Qt properties (<font face="monospace">self.someQtProperty<b>()</b></font>,
note the parentheses).<br>
<br>
I know that this might seem trivial, but it's something that
has slightly buggered me for some amount of time, mostly
because I often use the QObject constructor to automatically
set properties.</div>
<div><br>
</div>
<div>From the basic code perspective it's not that an issue: I
could set a custom property to _someProperty and then create
the related <font face="monospace">someProperty()</font> and
<font face="monospace">setSomeProperty(value)</font> functions
for "readability" reasons, but since I'm using some custom
made plugins in designer I'd prefer to keep property names as
clean as possible there too.</div>
<div>Obviously, using <font face="monospace">def
someProperty(self):</font> after the property declaration is
not an option, as it would make property access unavailable.<br>
</div>
<div><br>
</div>
<div>Note that I don't really care for some further lines in the
class definition/constructor; what I'd really prefer is to
always have a consistent way to access properties if they
*also are* Qt properties.<br clear="all">
<div><br>
</div>
<div>So, the question: is there a way or workaround to allow
creating a Qt property on PyQt that is still accessible
using the <font face="monospace">self.property()</font>
syntax, while keeping the property name intact?</div>
<div><br>
</div>
<div><br>
</div>
<div>Thanks,</div>
<div>Maurizio</div>
-- <br>
<div dir="ltr" data-smartmail="gmail_signature">È difficile
avere una convinzione precisa quando si parla delle ragioni
del cuore. - "Sostiene Pereira", Antonio Tabucchi<br>
<a href="http://www.jidesk.net" target="_blank"
moz-do-not-send="true">http://www.jidesk.net</a></div>
</div>
</div>
</blockquote>
</body>
</html>