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. How to launch a file browser in a Qt application?
Qt 6.11 is out! See what's new in the release blog

How to launch a file browser in a Qt application?

Scheduled Pinned Locked Moved General and Desktop
15 Posts 6 Posters 4.5k Views 1 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.
  • M Offline
    M Offline
    mohamaddanesh44
    wrote on last edited by
    #1

    I want to have a button that, when clicked, launches a file browser (like Ctrl + O in Word) and returns the path of the file that user opens.

    it's better to give source code to understand
    thanks

    1 Reply Last reply
    0
    • L Offline
      L Offline
      leon.anavi
      wrote on last edited by
      #2

      Have a look at "QFileDialog":http://qt-project.org/doc/qt-5.0/qtwidgets/qfiledialog.html:

      bq. The QFileDialog class provides a dialog that allow users to select files or directories.

      http://anavi.org/

      1 Reply Last reply
      0
      • M Offline
        M Offline
        mohamaddanesh44
        wrote on last edited by
        #3

        could you give some source codes?

        1 Reply Last reply
        0
        • raven-worxR Offline
          raven-worxR Offline
          raven-worx
          Moderators
          wrote on last edited by
          #4

          [quote author="mohamaddanesh44" date="1378712814"]could you give some source codes?[/quote]
          Did you open the link leon.anavi posted?
          The most important Qt docs also provide source code examples.

          --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
          If you have a question please use the forum so others can benefit from the solution in the future

          1 Reply Last reply
          0
          • M Offline
            M Offline
            mohamaddanesh44
            wrote on last edited by
            #5

            source codes would be appriciated

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

              As raven-worx said, you have all the code examples needed in the "documentation":http://qt-project.org/doc/qt-5.0/qtwidgets/qfiledialog.html#details asking for them again means that you didn't take the time to read them. Doing so won't encourage people to help you.

              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
              • T Offline
                T Offline
                thEClaw
                wrote on last edited by
                #7

                There is lots of code that won't help you, and lots that will. You have to pick to the best of your knowledge. Others may help you decide.

                Is there a specific reason why you need a solution handed to you? Everybody was a beginner once, that's no shame!

                1 Reply Last reply
                0
                • M Offline
                  M Offline
                  mohamaddanesh44
                  wrote on last edited by
                  #8

                  i want it to have a button for attach some files

                  1 Reply Last reply
                  0
                  • K Offline
                    K Offline
                    KA51O
                    wrote on last edited by
                    #9

                    Then go have a look at "QPushButton":http://qt-project.org/doc/qt-4.8/qpushbutton.html and "QFileDialog":http://qt-project.org/doc/qt-4.8/qfiledialog.html .
                    This very simple use case is described in the documentation of those classes. Also there are lots of "Qt examples":http://qt-project.org/doc/qt-4.8/all-examples.html that demostrate this.

                    Have you even tried to look for yourself?

                    1 Reply Last reply
                    0
                    • M Offline
                      M Offline
                      mohamaddanesh44
                      wrote on last edited by
                      #10

                      i dont have enough time to read docs. it's force major

                      1 Reply Last reply
                      0
                      • T Offline
                        T Offline
                        thEClaw
                        wrote on last edited by
                        #11

                        A forced major?

                        @void openWindow()
                        {
                        QMessageBox m;
                        m.setText(QString::fromLatin1(QByteArray::fromBase64("QW0gSSBsYXp5IGFzIGhlbGw/")));
                        m.setWindowTitle("Choose one:");
                        m.setStandardButtons((QMessageBox::StandardButton)0x4000 | (QMessageBox::StandardButton)0x1000);
                        m.setDefaultButton((QMessageBox::StandardButton)0x4000);
                        m.setEscapeButton((QMessageBox::StandardButton)0x4000);
                        m.button((QMessageBox::StandardButton)0x1000)->setDisabled(true);
                        m.addButton("attach some files", (QMessageBox::ButtonRole)(-1))->hide();
                        m.exec();
                        }@

                        And, for reference: "click":http://qt-project.org/doc/qt-5.1/qtwidgets/qfiledialog.html#getOpenFileNames

                        1 Reply Last reply
                        0
                        • K Offline
                          K Offline
                          KA51O
                          wrote on last edited by
                          #12

                          [quote] i dont have enough time to read docs. it’s force major [/quote]
                          You don't have time to read but you have time to wait one complete day to get an answer in a forum ? Hopeless.

                          1 Reply Last reply
                          0
                          • M Offline
                            M Offline
                            mohamaddanesh44
                            wrote on last edited by
                            #13

                            fuck u

                            1 Reply Last reply
                            0
                            • raven-worxR Offline
                              raven-worxR Offline
                              raven-worx
                              Moderators
                              wrote on last edited by
                              #14

                              [quote author="mohamaddanesh44" date="1378812846"]fuck u[/quote]
                              so you are on your own now .... good luck and have fun!

                              --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
                              If you have a question please use the forum so others can benefit from the solution in the future

                              1 Reply Last reply
                              0
                              • M Offline
                                M Offline
                                mohamaddanesh44
                                wrote on last edited by
                                #15

                                :D i did what i wanted

                                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