KDEAmbi/screen_capture_test.cpp

34 lines
895 B
C++

#include <QApplication>
#include <QMainWindow>
#include <QScreenCapture>
#include <QTimer>
#include <QDebug>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QMainWindow window;
window.setWindowTitle("Screen Capture Test");
window.resize(400, 300);
window.show();
QScreenCapture screenCapture;
QObject::connect(&screenCapture, &QScreenCapture::activeChanged, [&](bool active) {
qDebug() << "Screen capture active:" << active;
});
QObject::connect(&screenCapture, &QScreenCapture::errorOccurred, [&](QScreenCapture::Error error) {
qWarning() << "Screen capture error:" << error;
});
// Start screen capture after a short delay to ensure window is visible
QTimer::singleShot(1000, [&]() {
qDebug() << "Attempting to start screen capture...";
screenCapture.start();
});
return a.exec();
}