mirror of
https://github.com/zhuzichu520/FluentUI.git
synced 2025-03-15 08:29:41 +08:00
20 lines
493 B
C++
20 lines
493 B
C++
#include "FpsItem.h"
|
|
|
|
#include <QTimer>
|
|
#include <QQuickWindow>
|
|
|
|
FpsItem::FpsItem() {
|
|
_fps = 0;
|
|
auto *timer = new QTimer(this);
|
|
connect(timer, &QTimer::timeout, this, [this] {
|
|
fps(_frameCount);
|
|
_frameCount = 0;
|
|
});
|
|
connect(this, &QQuickItem::windowChanged, this, [this] {
|
|
if (window()) {
|
|
connect(window(), &QQuickWindow::afterRendering, this, [this] { _frameCount++; }, Qt::DirectConnection);
|
|
}
|
|
});
|
|
timer->start(1000);
|
|
}
|