Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Unsolved QFileDialog > look In as editable entry

    General and Desktop
    qfiledialog
    3
    11
    512
    Loading More Posts
    • 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
      Dariusz last edited by

      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 Reply Quote 0
      • mrjj
        mrjj Lifetime Qt Champion last edited by

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

        To give it a default name for saving.

        D 1 Reply Last reply Reply Quote 0
        • D
          Dariusz @mrjj last edited by

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

          mrjj 1 Reply Last reply Reply Quote 0
          • mrjj
            mrjj Lifetime Qt Champion @Dariusz last edited by

            @Dariusz

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

            1 Reply Last reply Reply Quote 0
            • mrjj
              mrjj Lifetime Qt Champion last edited by

              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 Reply Quote 0
              • D
                Dariusz @mrjj last edited by Dariusz

                @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 Reply Quote 0
                • D
                  Dariusz last edited by

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

                  mrjj 1 Reply Last reply Reply Quote 0
                  • mrjj
                    mrjj Lifetime Qt Champion @Dariusz last edited by

                    @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 Reply Quote 0
                    • B
                      Bonnie @mrjj last edited by 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);
                      });
                      
                      mrjj 1 Reply Last reply Reply Quote 1
                      • mrjj
                        mrjj Lifetime Qt Champion @Bonnie last edited by

                        @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 Reply Quote 0
                        • B
                          Bonnie @mrjj last edited by

                          @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 Reply Quote 1
                          • First post
                            Last post