See QWidget::render(). There is also an example for your situation!