Solved QFileDialog::getOpenFileName
-
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?
-
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 docQPushButton *okBtn = new QPushButton("ok", this); QObject::connect(okBtn,&QPushButton::clicked,this, &ClassName::slotName)
-
Doesn't this function open a static Dialog??
So how can i connect the button inside with a Signal? -
@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 .... }
-
Thank you very mutch, that is what i was looking for.