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. Clear File Selection in a QFileDialog
Forum Updated to NodeBB v4.3 + New Features

Clear File Selection in a QFileDialog

Scheduled Pinned Locked Moved Solved General and Desktop
qfiledialog
11 Posts 2 Posters 4.9k 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.
  • D Offline
    D Offline
    DougyDrumz
    wrote on last edited by
    #1

    How do you clear which files are selected in a QFileDialog?

    Dougy Drumz

    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi
      What do you mean by clear?
      The user selects files. or deselects them.

      1 Reply Last reply
      0
      • D Offline
        D Offline
        DougyDrumz
        wrote on last edited by
        #3

        I want to be able to programmatically deselect all highlighted files.

        Dougy Drumz

        mrjjM 1 Reply Last reply
        0
        • D DougyDrumz

          I want to be able to programmatically deselect all highlighted files.

          mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @DougyDrumz
          While the dialog is open?

          1 Reply Last reply
          0
          • D Offline
            D Offline
            DougyDrumz
            wrote on last edited by
            #5

            I've created a custom file dialog. I make one instance of it in my code. When I open that dialog I select a file name. When I open it again, the same file name is selected. I don't want it to be selected when I open it the second or succeeding time.

            Dougy Drumz

            mrjjM 1 Reply Last reply
            0
            • D DougyDrumz

              I've created a custom file dialog. I make one instance of it in my code. When I open that dialog I select a file name. When I open it again, the same file name is selected. I don't want it to be selected when I open it the second or succeeding time.

              mrjjM Offline
              mrjjM Offline
              mrjj
              Lifetime Qt Champion
              wrote on last edited by
              #6

              @DougyDrumz said:
              Ahh. a QFileDialog, yes?
              Have you tried to clear
              QStringList QFileDialog::selectedFiles()
              or
              yourdialog.selectFile( "");

              1 Reply Last reply
              0
              • D Offline
                D Offline
                DougyDrumz
                wrote on last edited by
                #7

                I had tried yourdialog.selectFile( "");, but that didn't seem to work. I'll try to clear selectedFiles().

                Dougy Drumz

                mrjjM 1 Reply Last reply
                0
                • D DougyDrumz

                  I had tried yourdialog.selectFile( "");, but that didn't seem to work. I'll try to clear selectedFiles().

                  mrjjM Offline
                  mrjjM Offline
                  mrjj
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  @DougyDrumz
                  ok. else if its completely stupid then maybe just new it each time and use
                  setAttribute( Qt::WA_DeleteOnClose );
                  to clean up?

                  As if you create new instance, its should be impossible for it to remember. :)

                  1 Reply Last reply
                  1
                  • D Offline
                    D Offline
                    DougyDrumz
                    wrote on last edited by
                    #9

                    Yeah. I thought about that too. Maybe I'm over-thinking this.

                    Dougy Drumz

                    mrjjM 1 Reply Last reply
                    0
                    • D DougyDrumz

                      Yeah. I thought about that too. Maybe I'm over-thinking this.

                      mrjjM Offline
                      mrjjM Offline
                      mrjj
                      Lifetime Qt Champion
                      wrote on last edited by
                      #10

                      @DougyDrumz
                      Well, one wonder where it remembers it.
                      Maybe its just the list itself.
                      so selectFile( ""); dont work as not select new and
                      selectedFiles is already empty.
                      so yeah, kill it ;)

                      1 Reply Last reply
                      1
                      • D Offline
                        D Offline
                        DougyDrumz
                        wrote on last edited by
                        #11

                        Thanks! That did the trick. However, I had to delete each instance by hand, instead if using Qt::WA_DeleteOnClose, because I was referencing data from the dialog after it was closed.

                        Dougy Drumz

                        1 Reply Last reply
                        1

                        • Login

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