Important: Please read the Qt Code of Conduct -

QGraphicsScene grab pixmap

  • class GraphicsScene : public QGraphicsScene
    void GraphicsScene::copy()
        QRectF rect(startPnt, endPnt);
        QPixmap pixmap = QPixmap::grabWindow(QApplication::desktop()->winId(), rect.x(), rect.y(), rect.width(), rect.height()); // but grab window below the QWidget
        //QPixmap pixmap = this->grab(rect); // has no member named ‘grab’
        QApplication::clipboard()->setPixmap(pixmap, QClipboard::Clipboard);

  • Lifetime Qt Champion

    There is even an example:

    QGraphicsScene scene;
    QPrinter printer(QPrinter::HighResolution);
    QPainter painter(&printer);

    You can use a pixmap instead of printer...

Log in to reply