In my ui I have a button, which adds QComboBox (with some items) and QLabel(with some text) when clicked. Variable "index" is the number of added QComboBoxes and QLabels. "ol" is qvector with some data.
void MainWindow::on_iAddOtherButton_clicked()
{
QComboBox *p1 = new QComboBox(this);
p1->setObjectName("comboBox"+QString::number(index));
QLabel *p2 = new QLabel(this);
p2->setObjectName("othLabel"+QString::number(index));
for(int i = 0; i < static_cast<int>(ol.size()); ++i){
p1->addItem(ol.at(i).getName());
ui->otherLayout->addWidget(p1,index+1,0);
}
p2->setText(...some text...));
ui->otherLayout->addWidget(p2,index+1,1);
index++;
}
And this works well, in the layout they are in pairs like this:
QComboBox1 QLabel1
QComboBox2 Qlabel2
Now I want to change value of the QComboBox1, after which, text of the QLabel1, will automatically change to something else.
I tried to do this with connect, but QComboBox on currentTextChanged()
emits only QString with a new value. Is there some way to emit name of object + new value?
Or there is some completely other solution to do this?