#include "ui_mainwindow.h "
Main window:: main window (q widget * parent):
QMainWindow (상위),
Ui (새 ui:: 주 창)
{
Ui-& gt;; SetupUi (이것);
이-> M _ timerid = 0;
이-> 연결 (ui-& gt;; 버튼, 신호 (clicked ()), this, slot (on _ start _ b _ clicked ());
이-> 연결 (ui-& gt;; PushButton_2, SIGNAL(clicked ()), this, slot (on _ stop _ b _ clicked ());
}
주 창:: ~ 주 창 ()
{
Ui 삭제
}
Void main window:: on _ start _ b _ clicked ()
//이것은 내가 정의한 버튼이다. 이 버튼을 누르면 다음 작업이 수행됩니다.
{
M _ timerid = this-> Starttimer (1000);
}
Void main window:: timerevent (qtimerevent * event)
{
Qstrings = ui-> Ms second-& gt;; Text ();
Ui-& gt;; Ms second-& gt;; Settext (qstring:: number (s.toint ()+1));
}
Void 주 창:: on _ stop _ b _ clicked()// 중지 버튼
{
If (m_timerid! = 0)
{
이-> Kill timer (this-> M _ timerid);
M _ timerid = 0;
}
}