Solved comboBox runtime enable/disable
-
@mpergand
it's very interesting..i can capture i var and pass it to a slot function
if i have understand..but once i have done it what i have to do??
slot function do what i need? -
The lambda function becomes the slot function.
You probably need to capture 'this' as well to get access to methods and vars of the class instance. -
@mpergand
thank you very much for your reply
but i don't think i'm able to do this..now i try to learn about lamba expression
-
This post is deleted! -
i've tried with this code:
connect(array_Origine[i], SIGNAL(currentTextChanged(QString)) [i] () { ATTDIS(i);} );
and with this:
connect(array_Origine[i], SIGNAL(currentTextChanged(QString)) [this, i] () { ATTDIS(i);} );
but give me this error:
called object type 'char' is not a function or function pointer
how can i solve it??
void inserisciarticolo::ATTDIS(int i) { if (array_Origine[i]->currentText() == "ESTERNA") { array_Fornitore[i]->setDisabled(false); array_Fornitore[i]->repaint(); } if (array_Origine[i]->currentText() == "INTERNA") { array_Fornitore[i]->setDisabled(true); array_Fornitore[i]->repaint(); } }
-
@TheCipo76 said in comboBox runtime enable/disable:
connect(array_Origine[i], SIGNAL(currentTextChanged(QString)) [this, i] () { ATTDIS(i);} );
connect(array_Origine[i], &QComboBox::currentTextChanged) [this, i] (QString str) { ATTDIS(i);} );
-
@mpergand said in comboBox runtime enable/disable:
connect(array_Origine[i], &QComboBox::currentTextChanged) [this, i] (QString str) { ATTDIS(i);} );
don't work..
'QString' does not refer to a value
error: no matching member function for call to 'connect'
-
QComboBox box; box.setEditable(true); QObject::connect(&box,&QComboBox::currentTextChanged,[](QString str) { qDebug()<<str; }); box.show();
works as expected ....
-
sorry typo:
connect(array_Origine[i], &QComboBox::currentTextChanged ) <- remove )
[this, i] (QString str) { ATTDIS(i);} ); -
Finally works!
i passed no parameters to the function ATTDIS():
call the function then
i check with a loop all members of array (with "for" i index) and when
find "ESTERNA" enable comboFornitore[i]
when find "INTERNA" disable comboFornitore[i]Thanks to all for patience and help gived
-
@Cobra91151 Thank you. It worked.