You could try using a delegate. Something like this:
#include <QtGui>
class Delegate : public QStyledItemDelegate
{
return QString("item %1").
arg(value.
toString());
}
};
int main(int argc, char *argv[])
{
comboBox.setEditable(true);
for (int i = 0; i<5; ++i){
comboBox.
addItem(QString("%1").
arg(i
));
}
comboBox.setItemDelegate(new Delegate);
comboBox.show();
return a.exec();
}
#include <QtGui>
class Delegate : public QStyledItemDelegate
{
QString displayText(const QVariant &value, const QLocale &locale) const{
return QString("item %1").arg(value.toString());
}
};
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QComboBox comboBox;
comboBox.setEditable(true);
for (int i = 0; i<5; ++i){
comboBox.addItem(QString("%1").arg(i));
}
comboBox.setItemDelegate(new Delegate);
comboBox.show();
return a.exec();
}
To copy to clipboard, switch view to plain text mode
Bookmarks