isan
26th April 2016, 07:04
I set a QcomboBox in gui widget and ,I add item
for(int i = 1; i < 31; i++)
{
ui->combo->addItem(QString::number(i));
}
and in QComboBox slot I want to get selected value by
int index =ui->combo->itemData( ui->combo->currentText());
but have error :316: error: no matching function for call to 'QComboBox::itemData(QString)'
if I use currentIndex instead of currentText return 0 when print it; addItem get Qstring ,
void QComboBox::addItem(const QString & text, const QVariant & userData = QVariant())
and ItemData work with currentIndex,
I use insertItem and it has sae error ,so how can set value or text and get slected value??
for(int i = 1; i < 31; i++)
{
ui->combo->addItem(QString::number(i));
}
and in QComboBox slot I want to get selected value by
int index =ui->combo->itemData( ui->combo->currentText());
but have error :316: error: no matching function for call to 'QComboBox::itemData(QString)'
if I use currentIndex instead of currentText return 0 when print it; addItem get Qstring ,
void QComboBox::addItem(const QString & text, const QVariant & userData = QVariant())
and ItemData work with currentIndex,
I use insertItem and it has sae error ,so how can set value or text and get slected value??