PDA

View Full Version : Signal/slot looking in base class, not derived class



georgie
12th May 2006, 06:21
the following code is part of a loop to initialise 100 electrodes

ElectrodeButton* eb = new ElectrodeButton(electrodeNumber, this, window);
electrodes.push_back(eb);
temp->move(x,y);

connect(eb, SIGNAL(focusChanged(int, int)), this, SIGNAL(currentChanged(int, int)));
connect(eb, SIGNAL(currentChanged(int, int)), eb, SLOT(updateFocus(int, int)));

this code above is meant so that clicking on any electrode (which emits focusChanged(int, int)) tells the parent array (which has initialised all electrodes) which then tells all of the electrodes to repaint in the appropriate manner (the electrodes are focussed in groups)....

now for some reason i get the runtime error

Object::connect: No such signal QWidget::focusChanged(int,int)
Object::connect: No such slot QWidget::updateFocus(int,int)
(x100)

this surprises me, because, although eb is a QWidget I would expect that it would be able to find the slot ElectrodeButton::updateFocus(int, int) and ElectrodeButton::focusChanged(int, int) and not go straight to QWidget to look for the members....

in the ElectrodeButton I do have

ElectrodeButton::ElectrodeButton(blah):QWidget(par ent){}
as part of it....but I would assume that it'd still work out that eb is of the ElectrodeButton type....

has anybody had similar problems?
is it just that my logic is wrong in the way these slots will work? i tried doing one at a time and the same thing happens...

jpn
12th May 2006, 06:52
Have you forgot to add Q_OBJECT macro to the header file of ElectrodeButton?

Edit: And if so, re-run qmake after adding the macro..

georgie
12th May 2006, 07:36
i think i just didn't work it out because it didn't barf on compilation....but i read the docs and worked out why now...thanks