A signal problem
-
Hi,
I have a QComboBox named cboBox,
void itemChanged(int);slot and a connection like this:connect(cboBox, SIGNAL(currentItemChanged(int)), this, SLOT(itemChanged(int))); ... void DialogTest::itemChanged(int item) { ... }But I get this error: QObject::connect: No such signal QComboBox::currentItemChanged(int)
-
Hi,
I have a QComboBox named cboBox,
void itemChanged(int);slot and a connection like this:connect(cboBox, SIGNAL(currentItemChanged(int)), this, SLOT(itemChanged(int))); ... void DialogTest::itemChanged(int item) { ... }But I get this error: QObject::connect: No such signal QComboBox::currentItemChanged(int)
@qcoderpro
Hi,
"But I get this error: QObject::connect: No such signal QComboBox::currentItemChanged(int)" means currentItemChanged isn't a signal.Maybe you want to write currentIndexChanged(int index).
-
@qcoderpro
Hi,
"But I get this error: QObject::connect: No such signal QComboBox::currentItemChanged(int)" means currentItemChanged isn't a signal.Maybe you want to write currentIndexChanged(int index).
-
Thank you. And if I want to use the new style, I need lambda, right?
I declared it this way but doesn't work:connect(cboBox, &QComboBox::currentIndexChanged, this, [this](int item) { itemChanged(item); });@qcoderpro said in A signal problem:
And if I want to use the new style, I need lambda, right?
Lambdas are a different thing...
You can achieve the same result by connecting your button to your slot like this:connect(cboBox, &QComboBox::currentIndexChanged, this, &DailogTest::itemChanged); -
@qcoderpro said in A signal problem:
And if I want to use the new style, I need lambda, right?
Lambdas are a different thing...
You can achieve the same result by connecting your button to your slot like this:connect(cboBox, &QComboBox::currentIndexChanged, this, &DailogTest::itemChanged); -
It doesn't work because the slot has two different versions, one int and another a string.
Error: no matching function
-
You're looking for qOverload() I guess