Hello,
Can i simply select strings with setCurrentIndex(int...) from a QComboBox and ->show()? or do i have to add a QStandardItemModel item?
In a widget i have a QComboBox with 3 strings at position 0,1,2
when i want to select a string, the ComboBox remains at item in position 0 := "MOD"
I found out that somewhat triggers the signal currentIndexChanged() 2 or 3 times, depending of setCurrentIndex(1) or setCurrentIndex(2) ????
Thank you for any advice,
Astronomy
//in the constructor..
m_ui->comboBoxINTYP->addItem("MOD");
m_ui->comboBoxINTYP->addItem("PEL");
m_ui->comboBoxINTYP->addItem("RHO");
// Another try without success..
// m_ui->comboBoxINTYP->insertItem(0,"MOD");
// m_ui->comboBoxINTYP->insertItem(1,"PEL");
// m_ui->comboBoxINTYP->insertItem(2,"RHO");
// Another try without success..
// m_ui->comboBoxINTYP->insertItem(0,"MOD",QVariant("MOD"));
// m_ui->comboBoxINTYP->insertItem(1,"PEL",QVariant("PEL"));
// m_ui->comboBoxINTYP->insertItem(2,"RHO",QVariant("RHO"));
//in the constructor..
m_ui->comboBoxINTYP->addItem("MOD");
m_ui->comboBoxINTYP->addItem("PEL");
m_ui->comboBoxINTYP->addItem("RHO");
// Another try without success..
// m_ui->comboBoxINTYP->insertItem(0,"MOD");
// m_ui->comboBoxINTYP->insertItem(1,"PEL");
// m_ui->comboBoxINTYP->insertItem(2,"RHO");
// Another try without success..
// m_ui->comboBoxINTYP->insertItem(0,"MOD",QVariant("MOD"));
// m_ui->comboBoxINTYP->insertItem(1,"PEL",QVariant("PEL"));
// m_ui->comboBoxINTYP->insertItem(2,"RHO",QVariant("RHO"));
To copy to clipboard, switch view to plain text mode
...reading values out data from a file and call setCurrentIndex()...
if(Ccoma08ctr.Get_INTYP() == "MOD")
{
m_ui->comboBoxINTYP->setCurrentIndex(0);
m_ui->comboBoxINTYP->show();
}
else if(Ccoma08ctr.Get_INTYP() == "PEL")
{
m_ui->comboBoxINTYP->setCurrentIndex(1);
m_ui->comboBoxINTYP->show();
}
else if(Ccoma08ctr.Get_INTYP() == "RHO")
{
cout << "index: RHO ist 2:" << endl;
m_ui->comboBoxINTYP->setCurrentIndex(2);
m_ui->comboBoxINTYP->show();
}
if(Ccoma08ctr.Get_INTYP() == "MOD")
{
m_ui->comboBoxINTYP->setCurrentIndex(0);
m_ui->comboBoxINTYP->show();
}
else if(Ccoma08ctr.Get_INTYP() == "PEL")
{
m_ui->comboBoxINTYP->setCurrentIndex(1);
m_ui->comboBoxINTYP->show();
}
else if(Ccoma08ctr.Get_INTYP() == "RHO")
{
cout << "index: RHO ist 2:" << endl;
m_ui->comboBoxINTYP->setCurrentIndex(2);
m_ui->comboBoxINTYP->show();
}
To copy to clipboard, switch view to plain text mode
looking at:
void ComaControlFile::on_comboBoxINTYP_currentIndexChanged(int index)
{
cout << "on_comboBoxINTYP_currentIndexChanged(int index): " << index << endl;
}
void ComaControlFile::on_comboBoxINTYP_currentIndexChanged(int index)
{
cout << "on_comboBoxINTYP_currentIndexChanged(int index): " << index << endl;
}
To copy to clipboard, switch view to plain text mode
setCurrentIndex(1) gives:
on_comboBoxINTYP_currentIndexChanged(int index): 0 //ok this is the constructor
index: PEL ist 1:
on_comboBoxINTYP_currentIndexChanged(int index): 1 //this is me.. ok
on_comboBoxINTYP_currentIndexChanged(int index): 0 //????
setCurrentIndex(2) gives:
on_comboBoxINTYP_currentIndexChanged(int index): 0 //ok this is the constructor
index: RHO ist 2:
on_comboBoxINTYP_currentIndexChanged(int index): 2 //this is me.. ok
on_comboBoxINTYP_currentIndexChanged(int index): 1 //???
on_comboBoxINTYP_currentIndexChanged(int index): 0 //???
Bookmarks