Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
How am i can handle signal "fileselected" (QFileDialog)?[SOLVED]
I have some problem with QFileDialog
@QFileDialog dialog = new QFileDialog(this,"Save Map","",".map");
connect(dialog, SIGNAL(fileSelected(QString)), this, SLOT(saveMap(QString)));@
When I clicked "OK" , signal "fileSelected" is sent twice
Xander84 last edited by
Hi, are you sure you are not connecting the signal twice? maybe you are calling that code twice in a function and never disconnect the signal so you will always add to the same signal. Just an idea.
You can try printing the "sender()" in the slot, see if its the same source or where it comes from.
I am sure that i'm not connecting the signal twice)
I printing sender() and i get same address twice)
Hi LiUn, what version of QT, which OS, and what are you attempting to accomplish?
I am using Qt5.2, os - ubuntu
I was trying disconnect from this signal when I getting it first time
@void MainWindow::saveMap(QString name)
but this doesn't work
Hi LiUn, I mean that I assume that you are attempting to save a file using the QFileDialog?
yes, I'm attempting to save a file using the QFileDialog
Hi LiUn, I'm not sure why you would want use connections for anything in this instance, but I recommend trying the following.
QString fileName = QFileDialog::getSaveFileName(this, "Save Maps", QDir::currentPath(), "Map Files (.map);;All Files (.*)");
Then fileName either holds the fileName entered, or nothing if cancel was pressed.
oh, thank you ... I think I can use this code instead my
You are welcome, don't forget to mark as [SOLVED] if it fixes your problem.