[PyKDE] Newbie pyQt user needs some slot help

Phil Thompson phil at river-bank.demon.co.uk
Thu May 4 17:29:47 BST 2000


Pete Ware wrote:
> 
> Phil Thompson <phil at river-bank.demon.co.uk> writes:
> 
> > I'd be interested to know, when people first started using PyQt/PyKDE,
> > what their biggest problem was.
> That you had to keep a python reference to qt objects around :-)
> 
>         self.widgets = []
>         button = qt.QPushButton (...)
>         self.widgets.append (button)
>         button = qt.QPushButton (...)
>         self.widgets.append (button)
>         ...

That's not as necessary as it used to be before v0.11.  The bindings now
know that a QObject is responsible for deleting its children and so
Python doesn't do it when the Python object is deleted.  This means (if
it has a parent) you don't need to keep a reference to the Python object
- unless you still want access to the Python part (eg. you have
connected a signal to a Python method of the object).

> My next problem was when I did call something with the wrong type
> arguments, I was frequently slow to figure out which argument was
> wrong -- the error message doesn't say it was the 3rd argument, for
> example.

The bindings can't tell what you intended, but they could include the
number of arguments successfully parsed.  For example if a class had the
following C++ functions...

	void foo(int,QObject *,QColor *)
	void foo(int,QRect *,QWidget *)

...and you called...

	foo(int,QRect *,QColor *)

...it would report a problem with the 3rd arg, although if you had
intended to call...

	foo(int,QObject *,QColor *)

...then the problem is actually with the 2nd arg.

Easy enough to implement if people think it would be useful???

Phil

> 
> --pete
> 
> _______________________________________________
> PyKDE mailing list    PyKDE at mats.gmd.de
> http://mats.gmd.de/mailman/listinfo/pykde




More information about the PyQt mailing list