Hello
My question today is:
How to add a picture to a Graphicsview .
I want to make it in the same size of Graphicsview.
Or ,if possible, I want to make it zoom-able.
Regards,
Printable View
Hello
My question today is:
How to add a picture to a Graphicsview .
I want to make it in the same size of Graphicsview.
Or ,if possible, I want to make it zoom-able.
Regards,
Or, you can instantiate a QGraphicsPixmapItem and give it to QGraphicsScene::addItem(). To be clear, you don't add anything to a QGraphicsView, which is nothing more than a "porthole", if you like, onto the QGraphicsScene, which contains all your pictures etc.
Thanks Lykurg .Thanks Urthas.
My Partner has been found it.
Code:
void MainWindow::on_pushButton_clicked() { scene->setBackgroundBrush(m.scaled(100,100,Qt::IgnoreAspectRatio,Qt::SmoothTransformation)); ui->graphicsView->setScene(scene); }
}
But We still don't Know How to make it in the same size of white rectangle.And how to make it zoom-able.
Thank you very much .
You can subclass QGraphicsView and in its paintEvent draw your picture scaled to the bounding rect.
Check the 40000 chips demo in Qt Demos.. you will get an idea how to zoom in / zoom out..