ostinato/common/intcombobox.h
Srivats P. 4dc3d2d7f9 - Added TODO instruction comments to the sample protocol
- Implemented ICMP protocol builder
- Added #ifdefs to intcombobox.h to prevent multiple inclusion
2010-03-17 15:47:56 +00:00

37 lines
777 B
C++

#ifndef __INT_COMBO_BOX
#define __INT_COMBO_BOX
#include <QComboBox>
class IntComboBox : public QComboBox
{
public:
IntComboBox(QWidget *parent = 0)
: QComboBox(parent)
{
}
void addItem(int value, const QString &text)
{
QComboBox::addItem(QString("%1 - %2").arg(value).arg(text), value);
}
int currentValue()
{
bool isOk;
int index = findText(currentText());
if (index >= 0)
return itemData(index).toInt();
else
return currentText().toInt(&isOk, 0);
}
void setValue(int value)
{
int index = findData(value);
if (index >= 0)
setCurrentIndex(index);
else
setEditText(QString().setNum(value));
}
};
#endif