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. QTemporaryFile move?
Forum Updated to NodeBB v4.3 + New Features

QTemporaryFile move?

Scheduled Pinned Locked Moved Solved General and Desktop
8 Posts 3 Posters 629 Views
  • 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.
  • fcarneyF Offline
    fcarneyF Offline
    fcarney
    wrote on last edited by fcarney
    #1

    Does QTemporaryFile have move or copy semantics?

    For instance:

    QTemporaryFile file;
    QVector<QTemporaryFile> files;
    files.push(file);  
    

    At this point if file goes out of scope I expect file to be deleted, unless I set autodelete to false. Or did the object get moved. Or am I thinking of references? At any rate I want the files vector to determine when files are deleted when it goes out of scope or is destroyed

    C++ is a perfectly valid school of magic.

    1 Reply Last reply
    0
    • fcarneyF Offline
      fcarneyF Offline
      fcarney
      wrote on last edited by
      #2

      Nevermind, it wont let me do that. I have to create a list of pointers.

      C++ is a perfectly valid school of magic.

      1 Reply Last reply
      0
      • Christian EhrlicherC Offline
        Christian EhrlicherC Offline
        Christian Ehrlicher
        Lifetime Qt Champion
        wrote on last edited by
        #3

        Why don't you simply test it by yourself? Apart from this I don't see a move ctor anywhere in the documentation.

        Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
        Visit the Qt Academy at https://academy.qt.io/catalog

        1 Reply Last reply
        1
        • fcarneyF Offline
          fcarneyF Offline
          fcarney
          wrote on last edited by
          #4

          @Christian-Ehrlicher
          I didn't see any move stuff there either. However, when I attempted to do it the compiler complained about items being private in the context of the vector template. So I just went ahead and did it with pointers. I just have to clean up the pointers afterwards.

          Btw, this is a really easy method of generating temp html files to be viewed by an external browser. I added it as a qml function to create a temp, put html data in it and then return the url so I can open in external browser using Qt.openUrlExternally.

          C++ is a perfectly valid school of magic.

          JonBJ 1 Reply Last reply
          0
          • fcarneyF fcarney

            @Christian-Ehrlicher
            I didn't see any move stuff there either. However, when I attempted to do it the compiler complained about items being private in the context of the vector template. So I just went ahead and did it with pointers. I just have to clean up the pointers afterwards.

            Btw, this is a really easy method of generating temp html files to be viewed by an external browser. I added it as a qml function to create a temp, put html data in it and then return the url so I can open in external browser using Qt.openUrlExternally.

            JonBJ Offline
            JonBJ Offline
            JonB
            wrote on last edited by
            #5

            @fcarney said in QTemporaryFile move?:

            Btw, this is a really easy method of generating temp html files to be viewed by an external browser.

            Do you know when to keep/destroy these temporary files?

            fcarneyF 1 Reply Last reply
            0
            • JonBJ JonB

              @fcarney said in QTemporaryFile move?:

              Btw, this is a really easy method of generating temp html files to be viewed by an external browser.

              Do you know when to keep/destroy these temporary files?

              fcarneyF Offline
              fcarneyF Offline
              fcarney
              wrote on last edited by
              #6

              @jonb The object itself on destruction destroys the temp file, or on Linux it looks like it stores in the /tmp directory so it gets destroyed by the os. I destroy these objects when the program quits. So the soonest the file will be destroyed is when the app is closed.

              C++ is a perfectly valid school of magic.

              JonBJ 1 Reply Last reply
              1
              • fcarneyF fcarney

                @jonb The object itself on destruction destroys the temp file, or on Linux it looks like it stores in the /tmp directory so it gets destroyed by the os. I destroy these objects when the program quits. So the soonest the file will be destroyed is when the app is closed.

                JonBJ Offline
                JonBJ Offline
                JonB
                wrote on last edited by
                #7

                @fcarney
                Yes, just potentially a lot of temporary HTML files hanging around while the app is running :)

                As for

                stores in the /tmp directory so it gets destroyed by the os

                I think that means on reboot, which could/should "never happen"....

                fcarneyF 1 Reply Last reply
                0
                • JonBJ JonB

                  @fcarney
                  Yes, just potentially a lot of temporary HTML files hanging around while the app is running :)

                  As for

                  stores in the /tmp directory so it gets destroyed by the os

                  I think that means on reboot, which could/should "never happen"....

                  fcarneyF Offline
                  fcarneyF Offline
                  fcarney
                  wrote on last edited by
                  #8

                  @jonb said in QTemporaryFile move?:

                  potentially a lot of temporary HTML files hanging around while the app is running

                  Yeah, that is a potential. They are small and are tied to printing. The idea is to use external app to print this.

                  C++ is a perfectly valid school of magic.

                  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