Raven Core  3.0.0
P2P Digital Currency
qvaluecombobox.cpp
Go to the documentation of this file.
1 // Copyright (c) 2011-2016 The Bitcoin Core developers
2 // Copyright (c) 2017-2019 The Raven Core developers
3 // Distributed under the MIT software license, see the accompanying
4 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
5 
6 #include "qvaluecombobox.h"
7 
9  QComboBox(parent), role(Qt::UserRole)
10 {
11  connect(this, SIGNAL(currentIndexChanged(int)), this, SLOT(handleSelectionChanged(int)));
12 }
13 
14 QVariant QValueComboBox::value() const
15 {
16  return itemData(currentIndex(), role);
17 }
18 
19 void QValueComboBox::setValue(const QVariant &value)
20 {
21  setCurrentIndex(findData(value, role));
22 }
23 
24 void QValueComboBox::setRole(int _role)
25 {
26  this->role = _role;
27 }
28 
30 {
31  Q_EMIT valueChanged();
32 }
void valueChanged()
QVariant value() const
void handleSelectionChanged(int idx)
void setValue(const QVariant &value)
QValueComboBox(QWidget *parent=0)
void setRole(int role)
Specify model role to use as ordinal value (defaults to Qt::UserRole)