Deleting file after creating QPixmap
-
Hi there, Will everything work properly if I delete image file after creating QPixmap with this image.
self.avatar_pixmap = QPixmap("example.png")
For example I will run this code and then delete the example.png file. Will pixmap still keep visible and will it work properly after?
-
Hi, welcome to the forum.
Yes, QPixmap loads image data from file into memory. There's no connection to the source file maintained after that. You can do whatever you want with it.
-
Hi and welcome to devnet,
Will you be able to use the QPixmap object ? Yes
The file content will have been loaded and is not needed anymore.Out of curiosity, what is your use case ?
-
Hi and welcome to devnet,
Will you be able to use the QPixmap object ? Yes
The file content will have been loaded and is not needed anymore.Out of curiosity, what is your use case ?
@SGaist I'm making a pet project with PyQt5. It's messenger. I would like users avatar images to be stored at server storage and loaded from there by client. My idea was to load all images, make qpixelmaps with them and delete image files by no need. So I was wondering will the pixelmap work properly after theese manipulation. But now I realised, that I shouldn't delete all images, but store them as cache.