Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Deleting file after creating QPixmap
Forum Updated to NodeBB v4.3 + New Features

Deleting file after creating QPixmap

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 3 Posters 312 Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    afobeus
    wrote on last edited by
    #1

    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?

    1 Reply Last reply
    0
    • Chris KawaC Offline
      Chris KawaC Offline
      Chris Kawa
      Lifetime Qt Champion
      wrote on last edited by
      #2

      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.

      1 Reply Last reply
      1
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #3

        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 ?

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        A 1 Reply Last reply
        1
        • SGaistS SGaist

          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 ?

          A Offline
          A Offline
          afobeus
          wrote on last edited by
          #4

          @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.

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved