Hello!

I'm having a problem with connect() function and I wasn't able to find a solution exactly despite numerous related problems have being reported in this forum.

the problem is: always when I want to make a connect() between a not-ui declared QPushButton and a slot function in a given thing ether the compiler returns error saying "no matching function for call ..." or else its says, when I run the software, that it couldn't find the slot.

So here is my situation: I'm creating a software that has a MenuBar with one of the options being "Settings". In the settings (a QWidget) there will be a couple of boxes and RadioButton and so forth to choose a couple of options to change my software. In order to make things simpler, I decided to create a specific class for almost all the windows (QWidgets, normally) that will be openend by clicking in the MenuBar.

The logic is supposed to be as follow:

1. in the MainWindow (that is connected with the ui and so its the place where the MenuBar click will be called) a pointer to the class with the Setings parameters is created. If the button in MenuBar "Settings" is pressed, a function opens a correspondent method in the windows class.

2. There, one of the automatic methods that are called is one that creates and connects all the buttons in the Settings window:

Qt Code:
  1. void MenuWindows::createSettingsBut()
  2. {
  3. //Cria botões de clique
  4. v_butOK = new QPushButton("OK");
  5. v_butCAN = new QPushButton("Cancela");
  6. connect(v_butOK, SIGNAL (released()), this, SLOT (update()));
  7. connect(v_butCAN, SIGNAL( released() ), v_setboxwidget, SLOT( close() ) );
  8.  
  9. //Cria ComboBox (que dá para escolher várias opções) - Qt19
  10. v_combobut1 = new QComboBox(v_setboxwidget);
  11. v_combobut1->addItem("Green");
  12. v_combobut1->addItem("GBR");
  13.  
  14. //Cria botões de escolha (radio) - Qt18
  15. v_radiobut1 = new QRadioButton("Op 1");
  16. ...
  17. }
To copy to clipboard, switch view to plain text mode 

one of this buttons is "v_butOK", which is a QPushButton with "OK" on it.

3. So the guy using the software will set the configurations in the other buttons as he pleases, and once he wants to get out with the new configuration, he press "OK".

4. In this case, the "OK" QPushButton must be connected with a slot method of the class (class name is "MenuWindows" as seen above) which is named "update()". This method will verify each of the settings parameters to see which changes were made and, based in the analysis, will change the configurations of the software and close the Settings window:

Qt Code:
  1. void MenuWindows::update()
  2. {
  3. if (v_checkbut1->isChecked())
  4. {
  5. qDebug() << "Graph 1 on.";
  6. }
  7. else
  8. {
  9. qDebug() << "Graph 1 off.";
  10. }
  11. if (v_checkbut2->isChecked())
  12. {
  13. qDebug() << "Graph 2 on.";
  14. }
  15. else
  16. {
  17. qDebug() << "Graph 2 off.";
  18. }
  19. v_setboxwidget->close();
  20. }
To copy to clipboard, switch view to plain text mode 
Note: this method is not finished (this is why there is just qDebugs() in it).

In the case, this update() method was declared as "public slots:" in the header file of the class "MenuWindows".

But when I run the software as it is above, the compilation says "Object::connect: No such slot QObject::update() in menuwindows.cpp:28". And the slot is there!

What am I missing?


Thanks!