PDA

View Full Version : How to draw bitmap from external file on the form?



ljiljan
20th February 2016, 07:21
I am using QT Creator 3.5.0 on Ubuntu 15.10. I have one form (mainwindow.ui) and I draw one GraphicView object (QGraphicsView) and one button (QPushButton). Signal on_pushButton_clicked() is created.

How to draw image from external file (BMP/ JPG/ PNG) on GraphicView object (that already exists) on the specific coordinates inside GraphicView object (x, y) when I click on the QPushButton?

anda_skoa
20th February 2016, 09:08
Create a QPixmap object, let it load the file, put it into a new QGraphicsPixmapItem, put that into the view's scene, move it to the position you want it to be.

Cheers,
_