You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
#include "qvaluecombobox.h"
|
|
|
|
|
|
|
|
QValueComboBox::QValueComboBox(QWidget *parent) :
|
|
|
|
QComboBox(parent), role(Qt::UserRole)
|
|
|
|
{
|
|
|
|
connect(this, SIGNAL(currentIndexChanged(int)), this, SLOT(handleSelectionChanged(int)));
|
|
|
|
}
|
|
|
|
|
|
|
|
QVariant QValueComboBox::value() const
|
|
|
|
{
|
|
|
|
return itemData(currentIndex(), role);
|
|
|
|
}
|
|
|
|
|
|
|
|
void QValueComboBox::setValue(const QVariant &value)
|
|
|
|
{
|
|
|
|
setCurrentIndex(findData(value, role));
|
|
|
|
}
|
|
|
|
|
|
|
|
void QValueComboBox::setRole(int role)
|
|
|
|
{
|
|
|
|
this->role = role;
|
|
|
|
}
|
|
|
|
|
|
|
|
void QValueComboBox::handleSelectionChanged(int idx)
|
|
|
|
{
|
|
|
|
emit valueChanged();
|
|
|
|
}
|