what does this operation show in console?
Qt Code:
  1. qDebug() << connect(w->toolButton(), SIGNAL(clicked()), this, SLOT(test()));
To copy to clipboard, switch view to plain text mode 
did you add Q_OBJECT macro in your class declaration.
PS. I've just tested both of these approaches and they work fine for me.