Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

how to viewpoert size of frameSize save only the canvas not the scrollbars of QWidget



  • In continutaion with
    https://forum.qt.io/topic/80540/how-to-save-the-pixmap-of-qwidget-without-borders-what-is-way-we-can-save-best-quality-image/6

    In the following code

    // view port is the only the QWidget- scrollbars
    5111 QPixmap *pixmap = new QPixmap(viewport()->size());
    5112 // QPixmap *pixmap = new QPixmap(this->frameSize());
    5113 QPainter painter;
    5114 painter.begin(pixmap);
    5115 render(&painter);
    5116 painter.end();
    5117 pixmap->save(fileName);
    5118 delete pixmap;
    5119 }

    or in following code
    5111 QPixmap *pixmap = new QPixmap(this->frameSzie());
    5112 // QPixmap *pixmap = new QPixmap(this->frameSize());
    5113 QPainter painter;
    5114 painter.begin(pixmap);
    5115 render(&painter);
    5116 painter.end();
    5117 pixmap->save(fileName);
    5118 delete pixmap;
    5119 }

    In this cases my QWidget saves only the visible part of QWidget without scrollbars . It will be helpful if some one can explain how

    viewport()->size() and this->frameSzie() tells the painter to save only visible part of canvas without scrollbars


Log in to reply