How am i can handle signal "fileselected" (QFileDialog)?[SOLVED]
-
Hello
I have some problem with QFileDialog@QFileDialog dialog = new QFileDialog(this,"Save Map","",".map");
dialog->setAcceptMode(QFileDialog::AcceptSave);
dialog->show();
connect(dialog, SIGNAL(fileSelected(QString)), this, SLOT(saveMap(QString)));@When I clicked "OK" , signal "fileSelected" is sent twice
-
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. -
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.