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::getOpenFileName

QFileDialog::getOpenFileName

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 3 Posters 1.3k 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
    meikelneit
    wrote on last edited by
    #1

    Hello,

    i have a Problem with this function. I am Looking to get a Directory of a file to open it later on.

    QString l_filePath = QFileDialog::getOpenFileName(this,tr("open directory"),QDir::homePath(),("*.db"));

    but how can i react on the different Buttons beeing pushed. When the OK button is pushed i want to execute another Funktion, how can i do that?

    ODБOïO 1 Reply Last reply
    0
    • M meikelneit

      Hello,

      i have a Problem with this function. I am Looking to get a Directory of a file to open it later on.

      QString l_filePath = QFileDialog::getOpenFileName(this,tr("open directory"),QDir::homePath(),("*.db"));

      but how can i react on the different Buttons beeing pushed. When the OK button is pushed i want to execute another Funktion, how can i do that?

      ODБOïO Offline
      ODБOïO Offline
      ODБOï
      wrote on last edited by
      #2

      Hi
      @meikelneit said in QFileDialog::getOpenFileName:

      but how can i react on the different Buttons beeing pushed.

      Connect buttons 'clicked' signal to the method you want to call
      see signals & slots doc

      QPushButton *okBtn = new QPushButton("ok", this);
      QObject::connect(okBtn,&QPushButton::clicked,this, &ClassName::slotName)
      
      1 Reply Last reply
      1
      • M Offline
        M Offline
        meikelneit
        wrote on last edited by
        #3

        Doesn't this function open a static Dialog??
        So how can i connect the button inside with a Signal?

        mrjjM 1 Reply Last reply
        0
        • M meikelneit

          Doesn't this function open a static Dialog??
          So how can i connect the button inside with a Signal?

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

          @meikelneit
          Hi
          with QFileDialog::getOpenFileName static call, if user press Cancel or close X the
          returned string will be empty.

          QString l_filePath = QFileDialog::getOpenFileName(this,tr("open directory"),QDir::homePath(),("*.db"));
          if ( ! l_filePath.isEmpty()  ) { // if user did select something
          ....
          }
          
          
          1 Reply Last reply
          5
          • M Offline
            M Offline
            meikelneit
            wrote on last edited by
            #5

            Thank you very mutch, that is what i was looking for.

            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