connect(ui->ComboBox,SIGNAL(currentIndexChanged()),this,SLOT(switchcall()));
in qt, combobox items i have none,server,client.when i select one of this it should call switchcall function.in this function i want to perform task depending upon choice in combobox.how to do it??
You haven't put the args in the SIGNAL
/SLOT
statements.
connect(ui->ComboBox,SIGNAL(currentIndexChanged(const QString&)),
this,SLOT(switchcall(const QString&)));
Alternatively you can use the item index, using the overloaded signal.
Use autoconnect:
void on_ComboBox_currentIndexChanged(int index);
Autoconnect template:
on_<control_name>_<signal_name>(<signal params>)
To get the index from QComboBox change event of QComboBox item use:
connect(ui->comboBox, SIGNAL(currentIndexChanged(int)),
this, SLOT(indexChanged(int)));
in mainwindow.h:
private slots:
void indexChanged(int index);
in mainwindow.cpp:
void MainWindow::indexChanged(int index)
{
// Do something here on ComboBox index change
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With