Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. how to viewpoert size of frameSize save only the canvas not the scrollbars of QWidget
Qt 6.11 is out! See what's new in the release blog

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

Scheduled Pinned Locked Moved Unsolved General and Desktop
1 Posts 1 Posters 392 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Q Offline
    Q Offline
    Qt Enthusiast
    wrote on last edited by
    #1

    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

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved