[prev in list] [next in list] [prev in thread] [next in thread]
List: pykde
Subject: Re: [PyQt] QPoint not automatically cast to QPointF
From: Shriramana Sharma <samjnaa () gmail ! com>
Date: 2012-09-20 11:31:46
Message-ID: CAH-HCWUL2nJ3631e5FJJS+hDT=tMB8L2itk4EchsK8ZNi5mMZA () mail ! gmail ! com
[Download RAW message or body]
[Attachment #2 (multipart/alternative)]
Hi. Thanks for your reply. What you have to do in SIP, is it of the nature
of a workaround to Python's inability to do the conversion automatically?
Or Python is able to do the conversion automatically and SIP just needs to
present the classes in a proper manner as required by Python?
Sent from my Android phone
On Sep 20, 2012 2:19 PM, "Phil Thompson" <phil@riverbankcomputing.com>
wrote:
> On Thu, 20 Sep 2012 07:34:10 +0530, Shriramana Sharma <samjnaa@gmail.com>
> wrote:
> > In my recent work with Beziers I ran across this. A QPoint is *not*
> > automatically converted into a QPointF in Python/PyQt while it *is*
> > converted in C++:
> >
> > The following C++ code compiles fine:
> >
> > # include <QtCore/QPoint>
> > # include <QtGui/QPainterPath>
> > int main ( void ) {
> > QPainterPath p ;
> > QPoint p1 ( 100, 150 ), c1 ( 166, 250 ), c2 ( 234, 250 ), p2 (
> 300, 150
> )
> > ;
> > p . moveTo ( p1 ) ;
> > p . cubicTo ( c1, c2, p2 ) ;
> > }
> >
> > whereas its Python/PyQt equivalent:
> >
> > #! /usr/bin/env python3
> > from PyQt4 . QtCore import QPoint
> > from PyQt4 . QtGui import QPainterPath
> > p = QPainterPath ()
> > p1 = QPoint ( 100, 150 )
> > c1 = QPoint ( 166, 250 )
> > c2 = QPoint ( 234, 250 )
> > p2 = QPoint ( 300, 150 )
> > p . moveTo ( p1 )
> > p . cubicTo ( c1, c2, p2 )
> >
> > produces the following:
> >
> > Traceback (most recent call last):
> > File "./qpoint-test.py", line 11, in <module>
> > p . moveTo ( p1 )
> > TypeError: arguments did not match any overloaded call:
> > QPainterPath.moveTo(QPointF): argument 1 has unexpected type 'QPoint'
> > QPainterPath.moveTo(float, float): argument 1 has unexpected type
> > 'QPoint'
> >
> > But QPointF in PyQt *does* provide a constructor from QPoint, so is
> > this the limitation of Python that it does not automatically check
> > whether it can convert one type to another to satisfy a function's
> > call signature? (Or is there some other fault in my PyQt code?)
> >
> > I realize I could always convert it manually using QPointF(p1) etc but
> > the assumption seems natural that an integer-precision numeric object
> > should be accepted where a float-precision can...
>
> It requires a change to SIP to handle this automatically which is on the
> TODO list but I haven't got round to it yet.
>
> Phil
>
[Attachment #5 (text/html)]
<p>Hi. Thanks for your reply. What you have to do in SIP, is it of the nature of a \
workaround to Python's inability to do the conversion automatically? Or Python is \
able to do the conversion automatically and SIP just needs to present the classes in \
a proper manner as required by Python?</p>
<p>Sent from my Android phone</p>
<div class="gmail_quote">On Sep 20, 2012 2:19 PM, "Phil Thompson" <<a \
href="mailto:phil@riverbankcomputing.com">phil@riverbankcomputing.com</a>> \
wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 \
.8ex;border-left:1px #ccc solid;padding-left:1ex"> On Thu, 20 Sep 2012 07:34:10 \
+0530, Shriramana Sharma <<a \
href="mailto:samjnaa@gmail.com">samjnaa@gmail.com</a>><br> wrote:<br>
> In my recent work with Beziers I ran across this. A QPoint is *not*<br>
> automatically converted into a QPointF in Python/PyQt while it *is*<br>
> converted in C++:<br>
><br>
> The following C++ code compiles fine:<br>
><br>
> # include <QtCore/QPoint><br>
> # include <QtGui/QPainterPath><br>
> int main ( void ) {<br>
> QPainterPath p ;<br>
> QPoint p1 ( 100, 150 ), c1 ( 166, 250 ), c2 ( 234, 250 ), p2 ( 300, \
150<br> )<br>
> ;<br>
> p . moveTo ( p1 ) ;<br>
> p . cubicTo ( c1, c2, p2 ) ;<br>
> }<br>
><br>
> whereas its Python/PyQt equivalent:<br>
><br>
> #! /usr/bin/env python3<br>
> from PyQt4 . QtCore import QPoint<br>
> from PyQt4 . QtGui import QPainterPath<br>
> p = QPainterPath ()<br>
> p1 = QPoint ( 100, 150 )<br>
> c1 = QPoint ( 166, 250 )<br>
> c2 = QPoint ( 234, 250 )<br>
> p2 = QPoint ( 300, 150 )<br>
> p . moveTo ( p1 )<br>
> p . cubicTo ( c1, c2, p2 )<br>
><br>
> produces the following:<br>
><br>
> Traceback (most recent call last):<br>
> File "./qpoint-test.py", line 11, in <module><br>
> p . moveTo ( p1 )<br>
> TypeError: arguments did not match any overloaded call:<br>
> QPainterPath.moveTo(QPointF): argument 1 has unexpected type \
'QPoint'<br> > QPainterPath.moveTo(float, float): argument 1 has \
unexpected type<br> > 'QPoint'<br>
><br>
> But QPointF in PyQt *does* provide a constructor from QPoint, so is<br>
> this the limitation of Python that it does not automatically check<br>
> whether it can convert one type to another to satisfy a function's<br>
> call signature? (Or is there some other fault in my PyQt code?)<br>
><br>
> I realize I could always convert it manually using QPointF(p1) etc but<br>
> the assumption seems natural that an integer-precision numeric object<br>
> should be accepted where a float-precision can...<br>
<br>
It requires a change to SIP to handle this automatically which is on the<br>
TODO list but I haven't got round to it yet.<br>
<br>
Phil<br>
</blockquote></div>
_______________________________________________
PyQt mailing list PyQt@riverbankcomputing.com
http://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