QScrollArea Timer Hack #2

This commit is contained in:
Mark Watkins 2011-08-07 22:53:42 +10:00
parent ff815b45ad
commit 3f207fcb37
2 changed files with 19 additions and 5 deletions

View File

@ -32,7 +32,8 @@ const int default_height=150;
MyScrollArea::MyScrollArea(QWidget *parent, Daily * daily)
:QScrollArea(parent),m_daily(daily)
{
timer=new QTimer(parent);
timer=new QTimer(this);
m_time.start();
}
MyScrollArea::~MyScrollArea()
{
@ -44,13 +45,22 @@ void MyScrollArea::scrollContentsBy(int dx, int dy)
//#ifdef Q_WS_MAC || Q_WS_WIN
if (timer->isActive()) timer->stop();
timer->setInterval(100);
timer->setSingleShot(true);
connect(timer,SIGNAL(timeout()),SLOT(RedrawGraphs()));
timer->setInterval(200);
connect(timer,SIGNAL(timeout()),SLOT(UpdateGraphs()));
timer->start();
m_time.start();
//m_daily->RedrawGraphs();
//#endif
}
void MyScrollArea::UpdateGraphs()
{
if (m_time.elapsed()<200)
return;
m_time.start();
//qDebug() << "Foo!";
m_daily->RedrawGraphs();
}
Daily::Daily(QWidget *parent,QGLWidget * shared, MainWindow *mw)
:QWidget(parent),mainwin(mw), ui(new Ui::Daily)

View File

@ -29,13 +29,18 @@ namespace Ui {
class Daily;
class MyScrollArea:public QScrollArea
{
Q_OBJECT
public:
MyScrollArea(QWidget * parent, Daily * daily);
virtual ~MyScrollArea();
protected slots:
void UpdateGraphs();
protected:
virtual void scrollContentsBy(int dx, int dy);
Daily *m_daily;
QTimer *timer;
QTime m_time;
};
class MainWindow;
@ -49,9 +54,8 @@ public:
void ReloadGraphs();
void ResetGraphLayout();
QGLWidget *SharedWidget() { return SF; }
public slots:
void RedrawGraphs();
private slots:
void on_calendar_currentPageChanged(int year, int month);