1
0
mirror of https://github.com/GOSTSec/gostcoin synced 2025-01-23 13:04:24 +00:00
gostcoin/src/qt/qvaluecombobox.cpp

28 lines
562 B
C++
Raw Normal View History

2017-03-22 11:56:18 -04:00
#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();
}