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