Qt, no such slot error

Posted by Martin Beckett on Stack Overflow See other posts from Stack Overflow or by Martin Beckett
Published on 2010-03-30T00:00:30Z Indexed on 2010/03/30 0:03 UTC
Read the original article Hit count: 531

Filed under:
|

I'm having a strange problem with slots in Qt4.6
I have a tree control that I am trying to fire an event back to the mainwindow to edit something.
I have boiled it down to this minimal example:

class MainWindow : public QMainWindow
{
    Q_OBJECT

    public:
       MainWindow(int argc, char **argv );

   private Q_SLOTS:     

  void about() {QMessageBox::about(this, "about","about"); } // Just the defaul about box
  void doEditFace() {QMessageBox::about(this, "test","doEditFace"); } // pretty identical

    ....
}


 class TreeModel : public QAbstractItemModel
 {

Q_OBJECT

    Q_SIGNALS:
    void editFace();
     ...
 }

In my Mainwindow() I have

connect(treeModel, SIGNAL(editFace()), this, SLOT(about())); // returns true
connect(treeModel, SIGNAL(editFace()), this, SLOT(doEditFace())); // returns false

When I run it the second line gives a warning.
Object::connect: No such slot MainWindow::doEditFace() in \src\mainwindow.cpp:588

As far as I can see the doEditFace() is in the moc_ qmeta class perfectly correctly.
And the edit event fires and pops up the about box. The order doesn't matterm if I connect the about box second it still works but my slot doesnt!

vS2008 windowsXP qt4.6.2

© Stack Overflow or respective owner

Related posts about c++

Related posts about qt4