I set a QcomboBox in gui widget and ,I add item
for(int i = 1; i < 31; i++)
{
ui
->combo
->addItem
(QString::number(i
));
}
for(int i = 1; i < 31; i++)
{
ui->combo->addItem(QString::number(i));
}
To copy to clipboard, switch view to plain text mode
and in QComboBox slot I want to get selected value by
int index =ui->combo->itemData( ui->combo->currentText());
int index =ui->combo->itemData( ui->combo->currentText());
To copy to clipboard, switch view to plain text mode
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())
To copy to clipboard, switch view to plain text mode
and ItemData work with currentIndex,
I use insertItem and it has sae error ,so how can set value or text and get slected value??
Bookmarks