7 MyWidget::MyWidget(QWidget
*parent
)
10 m_ui
= new Ui::MyWidgetBase();
13 m_numbers
= new QQueue
<int>;
15 connect(m_ui
->m_addButton
, SIGNAL(clicked(bool)), this,
16 SLOT(slot_addButtonClicked()));
18 connect(m_ui
->m_invButton
, SIGNAL(clicked(bool)), this,
19 SLOT(slot_invButtonClicked()));
21 connect(m_ui
->m_clrButton
, SIGNAL(clicked(bool)), this,
22 SLOT(slot_clrButtonClicked()));
30 void MyWidget::slot_addButtonClicked()
32 QString num
= m_ui
->m_lineEdit
->text();
36 m_numbers
->append(num
.toInt());
38 QString text
= m_ui
->m_label
->text();
40 m_ui
->m_label
->setText(text
);
41 m_ui
->m_lineEdit
->setText("");
44 void MyWidget::slot_invButtonClicked()
48 if (m_numbers
->isEmpty())
51 int count
= m_numbers
->count();
52 for (int i
= 0; i
< count
; i
++)
53 m_stack
.push(m_numbers
->dequeue());
56 for (int i
= 0; i
< count
; i
++)
57 text
+= QString::number(m_stack
.pop(), 10) + " ";
59 m_ui
->m_label
->setText(text
);
62 void MyWidget::slot_clrButtonClicked()
64 m_ui
->m_label
->setText("");
65 m_ui
->m_lineEdit
->setText("");