cpsmusic
6th July 2011, 14:01
Hi,
In another thread<http://www.qtcentre.org/threads/42858-Creating-a-Custom-FileOpen-Dialog> I asked about how to create a FileOpen dialog with additional controls. I've managed to get the dialog working and I've also been able to get the values from the custom controls. However, I can't figure out how to return the name of the file (from the standard FileOpen widget).
Here's what I've tried:
MyFileDialog *fd = new MyFileDialog;
fd->show();
if(fd->exec() == QDialog::Accepted) {
QString s1 = fd->trackLineEdit->text();
bool b;
unsigned int track = s1.toInt(&b, 10);
std::cout << "Track: " << track << std::endl;
QString s2 = fd->startTimeLineEdit->text();
unsigned int startTime = s2.toInt(&b, 10);
std::cout << "Start Time: " << startTime << std::endl;
QString fileName = fd-> ?? What goes here??
if (fileName.isEmpty()) {
return 1;
} else {
std::cout << fileName.toStdString() << std::endl;
}
}
The problem is in the third section - what do I have to do to return the file name?
Cheers,
Chris
In another thread<http://www.qtcentre.org/threads/42858-Creating-a-Custom-FileOpen-Dialog> I asked about how to create a FileOpen dialog with additional controls. I've managed to get the dialog working and I've also been able to get the values from the custom controls. However, I can't figure out how to return the name of the file (from the standard FileOpen widget).
Here's what I've tried:
MyFileDialog *fd = new MyFileDialog;
fd->show();
if(fd->exec() == QDialog::Accepted) {
QString s1 = fd->trackLineEdit->text();
bool b;
unsigned int track = s1.toInt(&b, 10);
std::cout << "Track: " << track << std::endl;
QString s2 = fd->startTimeLineEdit->text();
unsigned int startTime = s2.toInt(&b, 10);
std::cout << "Start Time: " << startTime << std::endl;
QString fileName = fd-> ?? What goes here??
if (fileName.isEmpty()) {
return 1;
} else {
std::cout << fileName.toStdString() << std::endl;
}
}
The problem is in the third section - what do I have to do to return the file name?
Cheers,
Chris