aboutsummaryrefslogtreecommitdiff
path: root/src-qt5/src-glwidgets/gltest/colorchange.h
blob: d62fcd5ca26ee55de3e32f6e636435a14bf4cf63 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include <QDebug>
#include <QApplication>
#include <QTimer>
#include <QColor>

#include "../glw-base.h"

class colorchange : public QObject{
	Q_OBJECT
private:
  GLW_Base *base;
  QTimer *timer;

public slots:
  void toggle(){
    static int current = 0;
    if(current==0){
      base->setBackgroundColor(QColor(Qt::red));
    }else{
      base->setBackgroundColor(QColor(Qt::blue));
      current = -1;
    }
    current++;
  }

public:
  colorchange(GLW_Base *parent) : QObject(){
    base = parent;
    timer = new QTimer(this);
    timer->setInterval(5000);
    connect(timer, SIGNAL(timeout()), this, SLOT(toggle()) );
    timer->start();
  }

};
bgstack15