Results 1 to 3 of 3

Thread: Signal/slot looking in base class, not derived class

  1. #1
    Join Date
    May 2006
    Location
    Australia
    Posts
    53
    Thanks
    11
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Signal/slot looking in base class, not derived class

    the following code is part of a loop to initialise 100 electrodes
    Qt Code:
    1. ElectrodeButton* eb = new ElectrodeButton(electrodeNumber, this, window);
    2. electrodes.push_back(eb);
    3. temp->move(x,y);
    4.  
    5. connect(eb, SIGNAL(focusChanged(int, int)), this, SIGNAL(currentChanged(int, int)));
    6. connect(eb, SIGNAL(currentChanged(int, int)), eb, SLOT(updateFocus(int, int)));
    To copy to clipboard, switch view to plain text mode 

    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
    Qt Code:
    1. ElectrodeButton::ElectrodeButton(blah):QWidget(parent){}
    To copy to clipboard, switch view to plain text mode 
    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...

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Signal/slot looking in base class, not derived class

    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..
    Last edited by jpn; 12th May 2006 at 07:57.
    J-P Nurmi

  3. The following 2 users say thank you to jpn for this useful post:

    Big_Stone88 (23rd March 2018), georgie (12th May 2006)

  4. #3
    Join Date
    May 2006
    Location
    Australia
    Posts
    53
    Thanks
    11
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Signal/slot looking in base class, not derived class

    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

Similar Threads

  1. Replies: 3
    Last Post: 27th December 2008, 20:34
  2. MVC - Abstract Widget Base Class - setupUI
    By SenSej in forum Newbie
    Replies: 0
    Last Post: 13th October 2008, 11:44
  3. Replies: 4
    Last Post: 19th March 2008, 18:47
  4. Connecting to a base class signal?
    By AaronMK in forum Qt Programming
    Replies: 4
    Last Post: 26th October 2007, 23:37
  5. Replies: 2
    Last Post: 20th September 2007, 13:27

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.