PDA

View Full Version : can I get another QGraphicsView's scene?



sincnarf
28th June 2007, 21:23
I want to print a QGraphicsScene's contents. How do I do this? The following code is wrong



void MainWindow::print()
{
QPrinter printer;
if (QPrintDialog(&printer).exec() == QDialog::Accepted) {
QPainter painter(&printer);
painter.setRenderHint(QPainter::Antialiasing);
//QGraphicsScene scene = anotherQGraphicsView->scene();
//What lines of code should I use to get another QGraphicsView's scene
//No method like getScene() exists
scene->render(&painter);
}
}

jpn
28th June 2007, 21:41
I'm not exactly sure what's the problem. :) Provided that you have access to pointer anotherQGraphicsView, it's ... something like this?


QGraphicsScene* scene = anotherQGraphicsView->scene();
scene->render(&painter);

Or is the problem about how to access some graphics view/scen to which you don't have a pointer at hand?