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. QFileDialog > look In as editable entry

QFileDialog > look In as editable entry

Scheduled Pinned Locked Moved Unsolved General and Desktop
qfiledialog
11 Posts 3 Posters 1.4k 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.
  • D Offline
    D Offline
    Dariusz
    wrote on last edited by
    #1

    Hey

    How can I configure / can I even do it? the Look in combo box to be an editable entry so I can copy/paste paths in to it ?

    TIA

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

      Hi
      You can use
      dialog->selectFile("myFileName");

      To give it a default name for saving.

      D 1 Reply Last reply
      0
      • mrjjM mrjj

        Hi
        You can use
        dialog->selectFile("myFileName");

        To give it a default name for saving.

        D Offline
        D Offline
        Dariusz
        wrote on last edited by
        #3

        @mrjj No, I want to be able to click on the top combo box that has paths and be able to copy/paste new path in to it. Like windows explorer.

        mrjjM 1 Reply Last reply
        0
        • D Dariusz

          @mrjj No, I want to be able to click on the top combo box that has paths and be able to copy/paste new path in to it. Like windows explorer.

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

          @Dariusz

          Do you mean when using Qt own dialogs and NOT the OS supplied ones ?

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

            Hi
            For me QFileDialog looks like this
            ![alt text](86984be4-2ead-443f-86b3-3c7c5778f359-image.png image url)

            and I can just paste a new path on top if i want.

            But when you say copy and paste.. do you then mean from code and not like a user ?

            D 1 Reply Last reply
            0
            • mrjjM mrjj

              Hi
              For me QFileDialog looks like this
              ![alt text](86984be4-2ead-443f-86b3-3c7c5778f359-image.png image url)

              and I can just paste a new path on top if i want.

              But when you say copy and paste.. do you then mean from code and not like a user ?

              D Offline
              D Offline
              Dariusz
              wrote on last edited by Dariusz
              #6

              @mrjj Hey Oh may, yeah my bad!! I should have tested it more before posting... I'm using

              saveWidget->setOption(QFileDialog::DontUseNativeDialog, true);
              

              The Qt one just has it as non editable combo box :- (((

              Copy paste, I mean in ur C:\wa\qthttpserver\ to be able to type in there/copy/paste/go to other link etc etc.

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

                Bump... any idea how to do it with qt widget not native os one?

                mrjjM 1 Reply Last reply
                0
                • D Dariusz

                  Bump... any idea how to do it with qt widget not native os one?

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

                  @Dariusz
                  Hi sorry. It sailed away.
                  We can always get hold of the live widget via findChildren
                  and try to set its property to editable. however, it might not work
                  as you expect as nothing will expect "edit" signals to come from it so not sure it will respond to you pasting stuff there but its worth a shot :)

                  B 1 Reply Last reply
                  0
                  • mrjjM mrjj

                    @Dariusz
                    Hi sorry. It sailed away.
                    We can always get hold of the live widget via findChildren
                    and try to set its property to editable. however, it might not work
                    as you expect as nothing will expect "edit" signals to come from it so not sure it will respond to you pasting stuff there but its worth a shot :)

                    B Offline
                    B Offline
                    Bonnie
                    wrote on last edited by Bonnie
                    #9

                    @mrjj
                    I can confirm that it doesn't work. Just tried that. :)
                    But we can also handle the signals since we are already cheating.

                    QComboBox *combo = saveWidget->findChild<QComboBox*>("lookInCombo", Qt::FindDirectChildrenOnly);
                    combo->setEditable(true);
                    QLineEdit *edit = combo->lineEdit();
                    connect(edit, &QLineEdit::returnPressed, saveWidget, [=](){
                        QString newPath = edit->text(); //TODO: verify the text is a valid path or not
                        saveWidget->setDirectory(newPath);
                    });
                    
                    mrjjM 1 Reply Last reply
                    1
                    • B Bonnie

                      @mrjj
                      I can confirm that it doesn't work. Just tried that. :)
                      But we can also handle the signals since we are already cheating.

                      QComboBox *combo = saveWidget->findChild<QComboBox*>("lookInCombo", Qt::FindDirectChildrenOnly);
                      combo->setEditable(true);
                      QLineEdit *edit = combo->lineEdit();
                      connect(edit, &QLineEdit::returnPressed, saveWidget, [=](){
                          QString newPath = edit->text(); //TODO: verify the text is a valid path or not
                          saveWidget->setDirectory(newPath);
                      });
                      
                      mrjjM Offline
                      mrjjM Offline
                      mrjj
                      Lifetime Qt Champion
                      wrote on last edited by
                      #10

                      @Bonnie
                      Hi
                      Super with the testing. :)

                      So with the usual disclaimer of breaking later on
                      as code is relying on internal details, its
                      can actually work ok. \o/

                      How did you find its name ?
                      dumpObjectTree()?

                      B 1 Reply Last reply
                      0
                      • mrjjM mrjj

                        @Bonnie
                        Hi
                        Super with the testing. :)

                        So with the usual disclaimer of breaking later on
                        as code is relying on internal details, its
                        can actually work ok. \o/

                        How did you find its name ?
                        dumpObjectTree()?

                        B Offline
                        B Offline
                        Bonnie
                        wrote on last edited by
                        #11

                        @mrjj
                        I read it from the qt source code.
                        I always do that when I want to cheat by using findChild / findChildren, to make sure I can find the right object.

                        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