Skip to content

Commit

Permalink
Print timer events as well.
Browse files Browse the repository at this point in the history
  • Loading branch information
Morten Johan Sørvig committed Feb 9, 2018
1 parent 2a8f714 commit bd7b2df
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
11 changes: 10 additions & 1 deletion gui_raster/rasterwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

RasterWindow::RasterWindow()
:m_eventCount(0)
,m_timeoutCount(0)
,m_pressed(false)
{
qDebug() << "RasterWindow()";
Expand All @@ -10,6 +11,13 @@ RasterWindow::RasterWindow()
QSurfaceFormat format;
format.setAlphaBufferSize(0);
setFormat(format);

QTimer *timer = new QTimer(this);
connect(timer, &QTimer::timeout, [this](){
++m_timeoutCount;
update();
});
timer->start(1000);
}

void RasterWindow::paintEvent(QPaintEvent * event)
Expand Down Expand Up @@ -37,7 +45,8 @@ void RasterWindow::paintEvent(QPaintEvent * event)
text += QString("Window Geometry: %1 %2 %3 %4\n").arg(g.x()).arg(g.y()).arg(g.width()).arg(g.height());
text += QString("Window devicePixelRatio: %1\n").arg(devicePixelRatio());
text += QString("Screen Geometry: %1 %2 %3 %4\n").arg(sg.x()).arg(sg.y()).arg(sg.width()).arg(sg.height());
text += QString("Received Event Count: %1\n").arg(m_eventCount);
text += QString("Received Events: %1\n").arg(m_eventCount);
text += QString("Received Timers: %1\n").arg(m_timeoutCount);

p.drawText(QRectF(0, 0, width(), height()), Qt::AlignCenter, text);
}
Expand Down
1 change: 1 addition & 0 deletions gui_raster/rasterwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ class RasterWindow : public QRasterWindow
private:
void incrementEventCount();
int m_eventCount;
int m_timeoutCount;
QPoint m_offset;
QPoint m_lastPos;
bool m_pressed;
Expand Down

0 comments on commit bd7b2df

Please sign in to comment.