-1

Object::connect: No such signal RollsRoyceTab::signal_aValueChange(int aValue)

In the following class:

class RollsRoyceTab : public QWidget
 {
     Q_OBJECT
 public:
     RollsRoyceTab(QWidget *parent = 0);
 public slots:
     void aValueChange(int);
     void rrValuesHolder(int aValue, int bValue, int cValue);
signals:
     void signal_aValueChange(int aValue);

 private:
     int aValue, bValue, cValue;
 };

And somewhere the connect, like:

connect(this,SIGNAL(signal_aValueChange(int aValue)),
    this,SLOT(rrValuesHolder(int aValue, int bValue, int cValue))); 

These are the actual implementations:

 void RollsRoyceTab::aValueChange(int aValue)
 {
     ...
     emit signal_aValueChange(aValue);
 }

void RollsRoyceTab::rrValuesHolder(int aValue, int bValue, int cValue)
 {
     qDebug() << aValue;
 }

What is the poper way to write the connect?
connect(... this,SLOT(rrValuesHolder(int aValue, int bValue, int cValue)));
or need write only one value SLOT(rrValuesHolder(int aValue))?

zerocukor287
  • 555
  • 2
  • 8
  • 23
Deng Won
  • 11
  • 5

2 Answers2

3

First: signals and slots in QObject::connect() should be without variables names.

Second: You can't connect signal with one argument with SLOT with three arguments. SIGNAL must not have fewer arguments than the SLOT.

It should be for e.g.:

connect(this,SIGNAL(signal_aValueChange(int)),this,SLOT(rrValuesHolder(int)));

And it's simply explanation for that. If you emit signal with one argument (for e.g. QString) how would slot know what are others two arguments? For me it's logical.

Blood
  • 4,126
  • 3
  • 27
  • 37
  • ok. connect(this,SIGNAL(signal_aValueChange(int, int, int)),this,SLOT(rrValuesHolder(int, int, int))); emit signal_aValueChange(aValue, bValue, cValue); – Deng Won Mar 11 '13 at 19:16
0

"SIGNAL() macro must NOT have fewer arguments than the signature passed to the SLOT() macro.

All of these would work:

connect(sender, SIGNAL(destroyed(QObject*)), this, SLOT(objectDestroyed(Qbject*)));
connect(sender, SIGNAL(destroyed(QObject*)), this, SLOT(objectDestroyed()));
connect(sender, SIGNAL(destroyed()), this, SLOT(objectDestroyed()));

This does not work:

connect(sender, SIGNAL(destroyed()), this, SLOT(objectDestroyed(QObject*)));

I believe you should call as value SLOT(rrValuesHolder(int))

Reference: http://qt-project.org/doc/qt-4.8/signalsandslots.html

EDIT: Blood included one additional piece of information that I neglected, Signals and Slots should be connected without variable names!

Alex Hendren
  • 446
  • 1
  • 5
  • 18