Reply
Thread Tools
Posts: 2 | Thanked: 0 times | Joined on Sep 2010
#1
Hi,
I'm fairly new to both Python and Qt4, so I'd like a few pointers to find out what my problem is.

The problem is that some QPushButtons won't signal the slots they're connected to when clicked, when running the program on my n900. When running the same program under Ubuntu 9.10 or 10.4, the method will execute without problems.

To add to the weirdness, the problem only affects some of the buttons, not all.

Code:
# this does NOT work:
self.b1[i]  = QtGui.QPushButton(self.quickButtons[i])
self.ds1[i] = Roller()
self.connect(self.b1[i],QtCore.SIGNAL('clicked()'),self.ds1[i].rollSlot)
Code:
# this WORKS:
self.throw_b  = QtGui.QPushButton("Throw")
self.connect(self.throw_b,QtCore.SIGNAL('clicked()'),self.genericRoll)
Any pointers on how I should debug this would be greatly appreciated. The only relevant difference I can think of is that n900 has Python2.5, whereas Ubuntu ships Python2.6.

OTOH, the new-style connect() (second example) does work... I am using the new-style connect(), am I not?
 
Posts: 3,319 | Thanked: 5,610 times | Joined on Aug 2008 @ Finland
#2
What comes to mind is that some of those objects might be, in some circumstances, garbage collected. Considering timing and version differences on the N900 it might easily make the difference between a segfault/missed signal and working app. But otherwise it would take a more complete example to reproduce/tell what's wrong.
__________________
Blogging about mobile linux - The Penguin Moves!
Maintainer of PyQt (see introduction and docs), AppWatch, QuickBrownFox, etc
 
Posts: 2 | Thanked: 0 times | Joined on Sep 2010
#3
Originally Posted by attila77 View Post
What comes to mind is that some of those objects might be, in some circumstances, garbage collected..
That was what I also thought, which is why I kept pointers in a list in order to inhibit garbage collection, but it didn't help. I had no segfaults or other errors.

Anyway, I decided to rework the strategy and created a class which inherited from QPushButton and put the connect() call in its __init__(). This worked, so I'm wondering whether it's an error to connect() to a method of another object of another class?
Code:
    # new call
    self.connect(self, QtCore.SIGNAL('clicked()'),self.rollSlot)
 
Khertan's Avatar
Posts: 1,012 | Thanked: 817 times | Joined on Jul 2007 @ France
#4
Hum this is strange ... i didn't have problem with qpushbutton slot.

Surely something else
 
Posts: 6 | Thanked: 3 times | Joined on May 2010
#5
Originally Posted by Alexander View Post
Hi,
I'm fairly new to both Python and Qt4, so I'd like a few pointers to find out what my problem is.

The problem is that some QPushButtons won't signal the slots they're connected to when clicked, when running the program on my n900. When running the same program under Ubuntu 9.10 or 10.4, the method will execute without problems.
That's strange, but not enough information to help diagnose the problem.

Originally Posted by Alexander View Post
Code:
# this does NOT work:
self.b1[i]  = QtGui.QPushButton(self.quickButtons[i])
self.ds1[i] = Roller()
self.connect(self.b1[i],QtCore.SIGNAL('clicked()'),self.ds1[i].rollSlot)
Code:
# this WORKS:
self.throw_b  = QtGui.QPushButton("Throw")
self.connect(self.throw_b,QtCore.SIGNAL('clicked()'),self.genericRoll)
Any pointers on how I should debug this would be greatly appreciated. The only relevant difference I can think of is that n900 has Python2.5, whereas Ubuntu ships Python2.6.
I would check that all the contents of self.ds1 are still present by the time the button emits the clicked() signal.

Originally Posted by Alexander View Post
OTOH, the new-style connect() (second example) does work... I am using the new-style connect(), am I not?
No, the new-style connect() would look something like this:

Code:
self.b1[i]  = QtGui.QPushButton(self.quickButtons[i])
self.ds1[i] = Roller()
self.b1[i].clicked.connect(self.ds1[i].rollSlot)
If you could show us some more code then we could maybe figure out why it's misbehaving.
 
Reply


 
Forum Jump


All times are GMT. The time now is 14:11.