That sounds like another good possibility since I could more or less choose what to display without any more hassle.
I've messed a bit with QGraphicsView's render() but I can't but get a grey square.
The relevant parts of what I did are:
label->setPixmap(*pixmap);
label->show();
pixmap = new QPixmap(800,600);
painter2 = new QPainter(pixmap);
label = new QLabel();
label->setPixmap(*pixmap);
label->show();
To copy to clipboard, switch view to plain text mode
And the following line gets called periodically:
scene->render(painter2, pixmap->rect(), ui->centralView->rect());
scene->render(painter2, pixmap->rect(), ui->centralView->rect());
To copy to clipboard, switch view to plain text mode
I've also tried putting the pixmap in a scene and that one on a QGraphicsView as well as rendering directly to a QDockWidget.
Added after 1 6 minutes:
I've discovered the function
qwidget.html#grab.html
QPixmap QWidget::grab(const QRect & rectangle = QRect( QPoint( 0, 0 ), QSize( -1, -1 ) ))
To copy to clipboard, switch view to plain text mode
which makes the rendering way more easy than using 'render'.
I did this:
QRect slaveRect
= ui
->centralWidget
->frameGeometry
().
united(ui
->dockWidget_3
->frameGeometry
());
label->setPixmap(this->grab(slaveRect));
QRect slaveRect = ui->centralWidget->frameGeometry().united(ui->dockWidget_3->frameGeometry());
label->setPixmap(this->grab(slaveRect));
To copy to clipboard, switch view to plain text mode
This is pretty close to what I wanted (maybe just use two labels instead of uniting the rects). I wonder if memory-wise is suitable, since we are creating pixmaps at every frame. I still feel there will be a better way of doing this. Cloning the two widgets or something.
Bookmarks