Posty

Wyświetlam posty z etykietą QT

[C++|QT] Zrzut ekranu

Ten wpis jest o tworzeniu zrzutu ekranu za pomocą biblioteki QT. Zacznijmy od utworzenia Qt Widgets Application w Qt Creator. main.cpp #include <QApplication> #include <QScreen> #include <QPixmap> #include <QDateTime> #include <QPushButton> #include <QVBoxLayout> #include <QWidget> #include <QMessageBox> class ScreenshotWidget : public QWidget { Q_OBJECT public: ScreenshotWidget() { // Ustawiamy tytuł okna dla programu setWindowTitle("Zrób zrzut ekranu"); // Tworzymy przycisk QPushButton *button = new QPushButton("Wykonaj zrzut", this); // Ustawiamy układ QVBoxLayout *layout = new QVBoxLayout(this); layout->addWidget(button); setLayout(layout); // Połączenie sygnału kliknięcia przycisku z funkcją takeScreenshot connect(button, &QPushButton::clicked, this, &ScreenshotWidget::takeScreenshot);...