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

List:       pykde
Subject:    Re: [PyQt] Fwd: QObject::connect: Parentheses expected, signal Actor::
From:       Maxime Lemonnier <maxime.lemonnier () gmail ! com>
Date:       2019-02-28 22:11:03
Message-ID: CAK_=Pd2yGNYU3h4yEcjgVtS42gfxXUfxxgeVuauEPL0nwAR=gg () mail ! gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


yes of course! Than you!

----- main.py ----------
import sys

from PyQt5.QtCore import QUrl, QObject, pyqtProperty as Property,
pyqtSignal as Signal
from PyQt5.QtQuick import QQuickView
from PyQt5.QtQml import qmlRegisterType
from PyQt5.QtGui import QGuiApplication, QOpenGLVersionProfile,
QSurfaceFormat


class MyClass(QObject):
    def __init__(self, parent = None):
        super(MyClass, self).__init__(parent)
        self._bar = None
    def get_bar(self):
        return self._bar
    def set_bar(self, p):
        self._bar = p
    barChanged = Signal()
    bar = Property(int, get_bar, set_bar, notify = barChanged)

qmlRegisterType(MyClass, "MyModule", 1, 0, "MyClass")

if __name__ == '__main__':
    app = QGuiApplication(sys.argv)
    view = QQuickView()
    view.setSource( QUrl.fromLocalFile('whatever.qml') )
    view.show()
    QGuiApplication.processEvents()
# you should see QObject::connect: Parentheses expected, signal MyClass::
in the console



---------- whatever.qml ---------------

import QtQuick 2.5
import MyModule 1.0
Rectangle
{
    height: 800
    width: 800
    color: "blue"

    MyClass
    {
        property var foo : [10,20,30]
        bar: foo[0]
    }
}


On Thu, Feb 28, 2019 at 5:01 PM Phil Thompson <phil@riverbankcomputing.com>
wrote:

> On 28 Feb 2019, at 9:10 pm, Maxime Lemonnier <maxime.lemonnier@gmail.com>
> wrote:
> >
> > When I derive a class from QObject and use it from qml, I get annoying
> warnings if I declare a property in the qml declaration, and bind that
> property anywhere.
> >
> > I get one
> >
> > 'QObject::connect: Parentheses expected, signal MyClass::'
> >
> > per binding, which can amount to a lot. so many in fact that it slows
> down startup time of my app significantly (.5s on Linux, 15-20s on Windoze).
> >
> > I can fix it by deriving from QQuickItem instead, but then I hit a
> mysterious:
> >
> > 'TypeError: a maximum of 30 QQuickItem types may be registered with QML'
> >
> > Where does this limitation comes from?, I get no hit from google on it.
>
> It's an arbitrary PyQt limit. It can be increased but I wouldn't want to
> (for example) increase it by 10x.
>
> If you have a short script that demonstrates the original problem I can
> look at it.
>
> Phil

[Attachment #5 (text/html)]

<div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr">yes of course! Than \
you!<div><br></div><div>----- main.py ----------</div><div><div>import \
sys</div><div><br></div><div>from PyQt5.QtCore import QUrl, QObject, pyqtProperty as \
Property, pyqtSignal as Signal</div><div>from PyQt5.QtQuick import \
QQuickView</div><div>from PyQt5.QtQml import qmlRegisterType</div><div>from \
PyQt5.QtGui import QGuiApplication, QOpenGLVersionProfile, \
QSurfaceFormat</div><div><br></div><div><br></div><div>class \
MyClass(QObject):</div><div>      def __init__(self, parent = None):</div><div>       \
super(MyClass, self).__init__(parent)</div><div>            self._bar = \
None</div><div>      def get_bar(self):</div><div>            return \
self._bar</div><div>      def set_bar(self, p):</div><div>            self._bar = \
p</div><div>      barChanged = Signal()</div><div>      bar = Property(int, get_bar, \
set_bar, notify = barChanged)</div><div><br></div><div>qmlRegisterType(MyClass, \
&quot;MyModule&quot;, 1, 0, &quot;MyClass&quot;)</div><div><br></div><div>if __name__ \
== &#39;__main__&#39;:</div><div>      app = QGuiApplication(sys.argv)</div><div>     \
view = QQuickView()</div><div>      view.setSource( \
QUrl.fromLocalFile(&#39;whatever.qml&#39;) )</div><div>      view.show()</div><div>   \
QGuiApplication.processEvents()</div></div><div># you should see  QObject::connect: \
Parentheses expected, signal MyClass:: in the \
console</div><div><br></div><div><br></div><div><br></div><div>---------- \
whatever.qml ---------------</div><div><br></div><div><div>import QtQuick \
2.5</div><div>import MyModule 1.0</div><div>Rectangle</div><div>{</div><div>      \
height: 800</div><div>      width: 800</div><div>      color: \
&quot;blue&quot;</div><div><br></div><div>      MyClass</div><div>      {</div><div>  \
property var foo : [10,20,30]</div><div>            bar: foo[0]</div><div>      \
}</div><div>}</div></div><div><br></div></div></div></div></div><br><div \
class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Feb 28, 2019 at 5:01 PM \
Phil Thompson &lt;<a \
href="mailto:phil@riverbankcomputing.com">phil@riverbankcomputing.com</a>&gt; \
wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px \
0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On 28 Feb 2019, at \
9:10 pm, Maxime Lemonnier &lt;<a href="mailto:maxime.lemonnier@gmail.com" \
target="_blank">maxime.lemonnier@gmail.com</a>&gt; wrote:<br> &gt; <br>
&gt; When I derive a class from QObject and use it from qml, I get annoying warnings \
if I declare a property in the qml declaration, and bind that property anywhere.<br> \
&gt; <br> &gt; I get one <br>
&gt; <br>
&gt; &#39;QObject::connect: Parentheses expected, signal MyClass::&#39;<br>
&gt; <br>
&gt; per binding, which can amount to a lot. so many in fact that it slows down \
startup time of my app significantly (.5s on Linux, 15-20s on Windoze).<br> &gt; <br>
&gt; I can fix it by deriving from QQuickItem instead, but then I hit a \
mysterious:<br> &gt; <br>
&gt; &#39;TypeError: a maximum of 30 QQuickItem types may be registered with \
QML&#39;<br> &gt; <br>
&gt; Where does this limitation comes from?, I get no hit from google on it. <br>
<br>
It&#39;s an arbitrary PyQt limit. It can be increased but I wouldn&#39;t want to (for \
example) increase it by 10x.<br> <br>
If you have a short script that demonstrates the original problem I can look at \
it.<br> <br>
Phil</blockquote></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