PDA

View Full Version : QFileDialog::getSaveFileName doesn't show file name.



cydside
22nd July 2009, 23:06
Hi to all,
I'm using Qt 2009.03 version and getting strange behavior with the following code:



QString nomeFile;
nomeFile = QString
(
"Export_%1.txt"
)
.arg(QDate::currentDate().toString("yyyy-MM-dd"));

qDebug() << "nomeFile : " << nomeFile;
//show exactly "Export_2009-07-23.txt"

QString nomeFileScelto = QFileDialog::getSaveFileName
(this, tr("Salva il File"), nomeFile,
tr("File da Esportare (Export*.txt)"));


it opens a Dialog (S.O.: Windows XP) without the suggested file name (nomeFile), just a blank box while the filter is OK!

The previous release didn't have that problem, if I remember right, any ideas?

wysota
22nd July 2009, 23:39
What if you prepend it with an absolute directory path?

cydside
22nd July 2009, 23:55
I've tried:




QString nomeFile;
nomeFile = QString
(
"./Export_%1.txt"
)
.arg(QDate::currentDate().toString("yyyy-MM-dd"));




QString nomeFile;
nomeFile = QString
(
".Export_%1.txt"
)
.arg(QDate::currentDate().toString("yyyy-MM-dd"));




QString nomeFile;
nomeFile = QString
(
"C:\Export_%1.txt"
)
.arg(QDate::currentDate().toString("yyyy-MM-dd"));



but nothing happen :(

cydside
23rd July 2009, 10:18
In the following way:



QString nomeFile;
nomeFile = QString
(
QDir::currentPath() + "/Export_%1.txt"
)
.arg(QDate::currentDate().toString("yyyy-MM-dd"));


it works!!! :D

thanks!