Qt QCombobox currentIndexChanged signal

2019-09-07 13:53发布

问题:

How get ItemIndex from one ComboBox and send to another ComboBox? Both Comb's created in QTableWidget

QComboBox *comboA = static_cast<QComboBox*>(ui->tableWidget->cellWidget(0,0));
QComboBox *comboB = static_cast<QComboBox*>(ui->tableWidget->cellWidget(0,1));
QObject::connect(comboA, SIGNAL(currentIndexChanged(int)),comboB, SLOT(setCurrentIndex(int)));

But this code does not work. Rather, it is necessary to define new methods for pointers.