[Ubuntu] 타이머

2013. 4. 12. 11:42OS/Ubuntu

1. 타이머헤더를 인클루드 해준다.

 #include <QTimer>


2. 타이머 객체를 선언한다.

QTimer *timer1;


3. 객체를 정의한다. 

   timer1 = new QTimer(this);

4. 작업할 내용을 생성한다.

void MainWindow::Lamp()
{

}

5. 슬롯을 생성한다.

private slots:

void Lamp();

6. 타이머객체의 슬롯을 연결한다.

connect(timer1, SIGNAL(timeout()), this, SLOT(Lamp()));


7. 타이머를 시작한다.

이때 start(주기)로 시작한다. 주기는 ms 단위로 반복된다.

   timer1->start(500);

'OS > Ubuntu' 카테고리의 다른 글

[Ubuntu] FTP  (0) 2016.02.28
[Ubuntu] SSH  (0) 2016.02.28
[Ubuntu] 레이블 색 변경  (0) 2013.04.12
[Ubuntu] 소리 출력  (0) 2013.04.12
[Ubuntu] 시리얼 통신  (0) 2013.04.12