How to create screenshot of QWidget?

前端 未结 2 2008
长情又很酷
长情又很酷 2021-02-08 00:58

I work at my homework in Qt Creator, where I paint to QWidget and I need to save some part of this QWdiget.

I tried to solve this problem:

 QPixmap pixma         


        
2条回答
  •  别那么骄傲
    2021-02-08 01:23

    You can use QWidget::render for this. Assuming rectangle is a QRect:

    QPixmap pixmap(rectangle->size()); 
    widget->render(&pixmap, QPoint(), QRegion(rectangle));
    

提交回复
热议问题