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" <p...@riverbankcomputing.com> wrote: > On Thu, 20 Sep 2012 07:34:10 +0530, Shriramana Sharma <samj...@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 >
_______________________________________________ PyQt mailing list PyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt