Important: Please read the Qt Code of Conduct -

Qt screenshot without start menu

  • Hello!

    I am trying to get a screenshot of my application, but I don't want the start menu. Do you know how to get this screenshot without the start menu?

    Here is my code:

    QScreen *screen = QGuiApplication::primaryScreen();
            if (const QWindow *window = windowHandle())
                screen = window->screen();
            if (!screen) {
            QPixmap originalPixmap = screen->grabWindow(0);
            QApplication::clipboard()->setPixmap(originalPixmap, QClipboard::Clipboard);
            QIcon icon2(":/ThermalAnalysis/Resources/ThermalAnalysis/screenshot.png");
            QMessageBox::information(NULL, "Screenshot", "Screenshot sent to clipboard.", QMessageBox::Ok);

    Thank you very much

  • Hi! You can use QWidget::grab() to grab only the widget you're interested in. E.g., to grab the central widget of a QMainWindow, use something like this:

    void MainWindow::on_pushButton_clicked()
        auto const pm = centralWidget()->grab();"/path/to/file.png");

Log in to reply