I got it working using a connect slot and a better alternative method too. No need to reply.
Added after 24 minutes:
The connect slot solution is:
connect(ui
->comboBox, static_cast<void
(QComboBox::*)(const QString &)>
(&QComboBox
::currentIndexChanged),
this,
&MainWindow
::setGames);
connect(ui->comboBox, static_cast<void (QComboBox::*)(const QString &)>(&QComboBox::currentIndexChanged), this, &MainWindow::setGames);
To copy to clipboard, switch view to plain text mode
An alternative and easier solution is:
void MainWindow
::on_comboBox_currentTextChanged(const QString &arg1
) {
if (arg1 == "first") {
ui->comboBox_2->clear();
ui->comboBox_2->addItem("1");
}
else if (arg1 == "second") {
ui->comboBox_2->clear();
ui->comboBox_2->addItem("2");
}
else if (arg1 == "third") {
ui->comboBox_2->clear();
ui->comboBox_2->addItem("3");
}
}
void MainWindow::on_comboBox_currentTextChanged(const QString &arg1)
{
if (arg1 == "first") {
ui->comboBox_2->clear();
ui->comboBox_2->addItem("1");
}
else if (arg1 == "second") {
ui->comboBox_2->clear();
ui->comboBox_2->addItem("2");
}
else if (arg1 == "third") {
ui->comboBox_2->clear();
ui->comboBox_2->addItem("3");
}
}
To copy to clipboard, switch view to plain text mode
Bookmarks