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 with no edit box
Qt 6.11 is out! See what's new in the release blog

QFileDialog with no edit box

Scheduled Pinned Locked Moved General and Desktop
16 Posts 5 Posters 5.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.
  • S samdol

    @kshegunov
    Sorry, but neither works,
    The first one just use non-native Filadialog which also has editbox.
    The second one crashes. It maybe there is no object named fileNameEdit on QFileDialog class. I tried to find an object name on QFileDialog.h but I could not see any.

    kshegunovK Offline
    kshegunovK Offline
    kshegunov
    Moderators
    wrote on last edited by
    #5

    What version are you using?

    Read and abide by the Qt Code of Conduct

    S 1 Reply Last reply
    0
    • kshegunovK kshegunov

      What version are you using?

      S Offline
      S Offline
      samdol
      wrote on last edited by
      #6

      @kshegunov
      I am using Version 5.5.0.
      Is it called differently?

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

        Hi,

        To add to @kshegunov, I'd search for QLineEdit rather than QWidget, that should narrow things a bit.

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

        S 1 Reply Last reply
        0
        • SGaistS SGaist

          Hi,

          To add to @kshegunov, I'd search for QLineEdit rather than QWidget, that should narrow things a bit.

          S Offline
          S Offline
          samdol
          wrote on last edited by
          #8

          @SGaist
          Still the same.
          If fileNameEdit is a name of object used in the library, how can I find it in source code.

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

            It's in qfiledialog.ui in Qt's sources.

            On which OS are you running that ?

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

            1 Reply Last reply
            0
            • S samdol

              @kshegunov
              I am using Version 5.5.0.
              Is it called differently?

              kshegunovK Offline
              kshegunovK Offline
              kshegunov
              Moderators
              wrote on last edited by
              #10

              @samdol said in QFileDialog with no edit box:

              I am using Version 5.5.0.

              Are you sure? @SGaist got ahead of me, but what OS are you running?

              Is it called differently?

              Not as far as I can see. You can check it yourself:
              http://code.qt.io/cgit/qt/qtbase.git/tree/src/widgets/dialogs/qfiledialog.ui?h=v5.5.0#n287

              @SGaist said in QFileDialog with no edit box:

              I'd search for QLineEdit rather than QWidget, that should narrow things a bit.

              Ordinarily I'd agree, however here it's a search by name and there's no gain in casting to line edit.

              Read and abide by the Qt Code of Conduct

              S 1 Reply Last reply
              1
              • kshegunovK kshegunov

                @samdol said in QFileDialog with no edit box:

                I am using Version 5.5.0.

                Are you sure? @SGaist got ahead of me, but what OS are you running?

                Is it called differently?

                Not as far as I can see. You can check it yourself:
                http://code.qt.io/cgit/qt/qtbase.git/tree/src/widgets/dialogs/qfiledialog.ui?h=v5.5.0#n287

                @SGaist said in QFileDialog with no edit box:

                I'd search for QLineEdit rather than QWidget, that should narrow things a bit.

                Ordinarily I'd agree, however here it's a search by name and there's no gain in casting to line edit.

                S Offline
                S Offline
                samdol
                wrote on last edited by
                #11

                @kshegunov
                I installed Qt 5.5.0 by
                qt-opensource-windows-x86-mingw492-5.5.0.exe
                I could not see qfiledialog.ui because, I think, it is not source code.
                If fileNameEdit is the correct name, I don't understand why it crashes.

                jsulmJ kshegunovK 2 Replies Last reply
                0
                • S samdol

                  @kshegunov
                  I installed Qt 5.5.0 by
                  qt-opensource-windows-x86-mingw492-5.5.0.exe
                  I could not see qfiledialog.ui because, I think, it is not source code.
                  If fileNameEdit is the correct name, I don't understand why it crashes.

                  jsulmJ Offline
                  jsulmJ Offline
                  jsulm
                  Lifetime Qt Champion
                  wrote on last edited by
                  #12

                  @samdol said in QFileDialog with no edit box:

                  If fileNameEdit is the correct name, I don't understand why it crashes

                  Probably because fileNameEdit is nullptr? This is easy to check.

                  https://forum.qt.io/topic/113070/qt-code-of-conduct

                  1 Reply Last reply
                  0
                  • S samdol

                    @kshegunov
                    I installed Qt 5.5.0 by
                    qt-opensource-windows-x86-mingw492-5.5.0.exe
                    I could not see qfiledialog.ui because, I think, it is not source code.
                    If fileNameEdit is the correct name, I don't understand why it crashes.

                    kshegunovK Offline
                    kshegunovK Offline
                    kshegunov
                    Moderators
                    wrote on last edited by
                    #13

                    @samdol said in QFileDialog with no edit box:

                    If fileNameEdit is the correct name, I don't understand why it crashes.

                    By "crashes" you probably mean you trip the assertion I've put. Why I don't know for sure, you should debug it and check against your sources (if those are not available, building Qt so you obtain a source tree corresponding to the binary, might be a good idea).

                    Read and abide by the Qt Code of Conduct

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

                      Just a silly idea: you didn't remove dialog.setOption(QFileDialog::DontUseNativeDialog); from your code, did you ?

                      If you are trying that with the native dialog it won't work.

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

                      S 1 Reply Last reply
                      2
                      • SGaistS SGaist

                        Just a silly idea: you didn't remove dialog.setOption(QFileDialog::DontUseNativeDialog); from your code, did you ?

                        If you are trying that with the native dialog it won't work.

                        S Offline
                        S Offline
                        samdol
                        wrote on last edited by
                        #15

                        @SGaist
                        Thank you SGaist and kshegunov,
                        I was silly, I should have put QFileDialog::DontUseNativeDialog.
                        Now with the following, I could hide fileNameEdit, filenameLabel and
                        buttonBox. It looks much better now. By the way, do we need QStringLiteral?

                            QFileDialog dialog(this, "Source Directory", directory);
                            dialog.setNameFilter(myFilter);
                            dialog.setOption(QFileDialog::DontUseNativeDialog);
                            QWidget * fileNameEdit = dialog.findChild<QWidget *>("fileNameEdit");
                            //QWidget * fileNameEdit = dialog.findChild<QWidget *>(QStringLiteral("fileNameEdit"));
                            Q_ASSERT(fileNameEdit);
                            fileNameEdit->setVisible(false);
                            QWidget * fileNameLabel = dialog.findChild<QWidget *>("fileNameLabel");
                            fileNameLabel->setVisible(false);
                            QWidget * buttonBox = dialog.findChild<QWidget *>("buttonBox");
                            buttonBox->setVisible(false);
                        
                            dialog.exec();
                        

                        '''

                        kshegunovK 1 Reply Last reply
                        0
                        • S samdol

                          @SGaist
                          Thank you SGaist and kshegunov,
                          I was silly, I should have put QFileDialog::DontUseNativeDialog.
                          Now with the following, I could hide fileNameEdit, filenameLabel and
                          buttonBox. It looks much better now. By the way, do we need QStringLiteral?

                              QFileDialog dialog(this, "Source Directory", directory);
                              dialog.setNameFilter(myFilter);
                              dialog.setOption(QFileDialog::DontUseNativeDialog);
                              QWidget * fileNameEdit = dialog.findChild<QWidget *>("fileNameEdit");
                              //QWidget * fileNameEdit = dialog.findChild<QWidget *>(QStringLiteral("fileNameEdit"));
                              Q_ASSERT(fileNameEdit);
                              fileNameEdit->setVisible(false);
                              QWidget * fileNameLabel = dialog.findChild<QWidget *>("fileNameLabel");
                              fileNameLabel->setVisible(false);
                              QWidget * buttonBox = dialog.findChild<QWidget *>("buttonBox");
                              buttonBox->setVisible(false);
                          
                              dialog.exec();
                          

                          '''

                          kshegunovK Offline
                          kshegunovK Offline
                          kshegunov
                          Moderators
                          wrote on last edited by
                          #16

                          @samdol said in QFileDialog with no edit box:

                          I was silly, I should have put QFileDialog::DontUseNativeDialog.

                          Yes, you must use the alien dialog if you want to manipulate it in such a way.

                          By the way, do we need QStringLiteral?

                          It's a macro that enables some string literal optimizations if your compiler supports them otherwise it defaults to QString("text"). I advise using it, although it's not strictly necessary.

                          Read and abide by the Qt Code of Conduct

                          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