8 MyWidget::MyWidget(QWidget
*parent
)
15 QVBoxLayout
*labels
= new QVBoxLayout();
17 m_label
= new QLabel("Binario", this);
18 labels
->addWidget(m_label
);
20 m_label
= new QLabel("Octal", this);
21 labels
->addWidget(m_label
);
23 m_label
= new QLabel("Decimal", this);
24 labels
->addWidget(m_label
);
26 m_label
= new QLabel("Hexadecimal", this);
27 labels
->addWidget(m_label
);
31 QVBoxLayout
*lines
= new QVBoxLayout();
32 for (int i
= 0; i
< NR_LABELS
; i
++) {
33 m_qlines
[i
] = new QLineEdit(this);
34 lines
->addWidget(m_qlines
[i
]);
35 connect(m_qlines
[i
], SIGNAL(textEdited(const QString
&)),
36 this, SLOT(m_update_lines()));
39 /* Put them together */
40 QHBoxLayout
*main_layout
= new QHBoxLayout(this);
41 main_layout
->addItem(labels
);
42 main_layout
->addItem(lines
);
49 void MyWidget::resetLines()
51 for (int i
= 0; i
< NR_LABELS
; i
++)
52 m_qlines
[i
]->setText("");
55 void MyWidget::m_update_lines()
59 for (i
= 0; i
< NR_LABELS
; i
++) {
60 if (m_qlines
[i
]->isModified()) {
61 if (m_qlines
[i
]->text() == "") {
84 int num
= m_qlines
[i
]->text().toInt(0, base
);
85 m_qlines
[0]->setText(QString::number(num
, 2));
86 m_qlines
[1]->setText(QString::number(num
, 8));
87 m_qlines
[2]->setText(QString::number(num
, 10));
88 m_qlines
[3]->setText(QString::number(num
, 16).toUpper());