[PyKDE] Problem with PyQt3

Detlev Offenbach detlev at die-offenbachs.de
Thu Dec 28 13:56:19 GMT 2006


On Thursday 28 December 2006 12:23, Phil Thompson wrote:
> On Thursday 28 December 2006 11:14 am, Detlev Offenbach wrote:
> > On Thursday 28 December 2006 11:41, Phil Thompson wrote:
> > > On Thursday 28 December 2006 9:14 am, Detlev Offenbach wrote:
> > > > On Wednesday 27 December 2006 23:37, Phil Thompson wrote:
> > > > > On Wednesday 27 December 2006 5:02 pm, Detlev Offenbach wrote:
> > > > > > On Wednesday 27 December 2006 17:58, Phil Thompson wrote:
> > > > > > > On Wednesday 27 December 2006 4:06 pm, Detlev Offenbach wrote:
> > > > > > > > Hi,
> > > > > > > >
> > > > > > > > I have an application with a dialog that was created with Qt
> > > > > > > > Designer and converted to Python with pyuic3. This dialog has
> > > > > > > > an ok and a cancel button. These buttons are connected to the
> > > > > > > > accept() and reject() slots. When I press one of the buttons,
> > > > > > > > I get the following error:
> > > > > > > >
> > > > > > > > RuntimeError: no access to protected functions or signals for
> > > > > > > > objects not created from Python
> > > > > > > >
> > > > > > > > What am I doing wrong?
> > > > > > > >
> > > > > > > > Versions:
> > > > > > > > Qt   3.3.7
> > > > > > > > PyQt 3.17
> > > > > > > > sip  snapshot-20061220
> > > > > > > >
> > > > > > > > all on a x86_64 machine with openSUSE 10.2. All PyQt related
> > > > > > > > stuff is self compiled.
> > > > > > >
> > > > > > > Have you got the .ui file? Is the problem reproducable with
> > > > > > > just the generated .py file and the -x flag?
> > > > > >
> > > > > > I have the .ui file available but unfortunately it is not
> > > > > > reproducable with just the generated .py file. The dialog itself
> > > > > > is generated from some Python code. It looks as if the dialog
> > > > > > doesn't really know it is a Python dialog.
> > > > >
> > > > > So how was the instance the exception was raised against created
> > > > > and what method were you calling?
> > > >
> > > > Problem found thanks to your questions. It was caused by a parent
> > > > object given to the dialog, which was not created from Python code.
> > > > The protected methods (slots) called by the dialog were accept() and
> > > > reject(). How a non Python created parent influences this is unclear
> > > > to me. Maybe this should be mentioned in the PyQt docs.
> > >
> > > A parent doesn't influence it - you just can't call protected methods
> > > of an object not created by Python (and Qt implements emit by calling a
> > > protected method).
> >
> > And that is exactly the weird thing with this situation. The dialog was
> > created by Python but the parent given to the dialog was not. After
> > changing the code giving the constructor of the dialog a parent object
> > created by Python (or None) made it work.
>
> Then either your code isn't working quite as you think it is, or something
> else is going on. Either way a test case would help.
>

And here is the test case, that shows the behavior. Just run main.py and press 
the button in the corner of the tab widget. It was tested with Python 2.5.

Detlev
-- 
Detlev Offenbach
detlev at die-offenbachs.de
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Bug.tar.gz
Type: application/x-tgz
Size: 2408 bytes
Desc: not available
Url : http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20061228/455d9e56/Bug.tar.bin


More information about the PyQt mailing list