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


Qt Code:
  1. //in the constructor..
  2.  
  3. m_ui->comboBoxINTYP->addItem("MOD");
  4. m_ui->comboBoxINTYP->addItem("PEL");
  5. m_ui->comboBoxINTYP->addItem("RHO");
  6.  
  7. // Another try without success..
  8. // m_ui->comboBoxINTYP->insertItem(0,"MOD");
  9. // m_ui->comboBoxINTYP->insertItem(1,"PEL");
  10. // m_ui->comboBoxINTYP->insertItem(2,"RHO");
  11.  
  12. // Another try without success..
  13. // m_ui->comboBoxINTYP->insertItem(0,"MOD",QVariant("MOD"));
  14. // m_ui->comboBoxINTYP->insertItem(1,"PEL",QVariant("PEL"));
  15. // 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()...
Qt Code:
  1. if(Ccoma08ctr.Get_INTYP() == "MOD")
  2. {
  3. m_ui->comboBoxINTYP->setCurrentIndex(0);
  4. m_ui->comboBoxINTYP->show();
  5. }
  6. else if(Ccoma08ctr.Get_INTYP() == "PEL")
  7. {
  8. m_ui->comboBoxINTYP->setCurrentIndex(1);
  9. m_ui->comboBoxINTYP->show();
  10. }
  11. else if(Ccoma08ctr.Get_INTYP() == "RHO")
  12. {
  13. cout << "index: RHO ist 2:" << endl;
  14. m_ui->comboBoxINTYP->setCurrentIndex(2);
  15. m_ui->comboBoxINTYP->show();
  16. }
To copy to clipboard, switch view to plain text mode 

looking at:
Qt Code:
  1. void ComaControlFile::on_comboBoxINTYP_currentIndexChanged(int index)
  2. {
  3. cout << "on_comboBoxINTYP_currentIndexChanged(int index): " << index << endl;
  4.  
  5. }
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 //???