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,
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,
thaihoangluu (22nd December 2011)
thaihoangluu (22nd December 2011)
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.
thaihoangluu (22nd December 2011)
Thanks Lykurg .Thanks Urthas.
My Partner has been found it.
Qt Code:
void MainWindow::on_pushButton_clicked() { scene->setBackgroundBrush(m.scaled(100,100,Qt::IgnoreAspectRatio,Qt::SmoothTransformation)); ui->graphicsView->setScene(scene); }To copy to clipboard, switch view to plain text mode
}
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 .
Last edited by Malek; 22nd August 2010 at 01:23.
thaihoangluu (22nd December 2011)
You can subclass QGraphicsView and in its paintEvent draw your picture scaled to the bounding rect.
thaihoangluu (22nd December 2011)
Check the 40000 chips demo in Qt Demos.. you will get an idea how to zoom in / zoom out..
thaihoangluu (22nd December 2011)
Bookmarks