Right now I'm working on a GUI for a suite of console applications used for bioinformatics and I'm doing my first tests as its my first project using Qt. I'm using QtDesigner for making the GUI and everything works perfectly except that QFileDialog converts the end of the file name into a strange character, although I'm not really sure if it is QFileDialog, or the conversion from QString into const char.
Here is my code:
QString file=QFileDialog::getOpenFileName(this, tr("Open File"),"/home/",tr("Any file (*.*)"));
QString fastqdumpDir = "/home/nsg/Downloads/sratoolkit.2.1.16-centos_linux32/bin/"
fastqdumpDir=fastqdumpDir+"./fastq-dump ";
QString cmdStr =fastqdumpDir + file;
const char* command = cmdStr.toStdString().c_str();
system(command);
The fastq-dump program ends because it says that the filename is not correct, and after debugging, I see that the file name goes from /home/nsg/Downloads/SRR502947.sra into /home/nsg/Downloads/SRR502947.sra[] and sometimes even /home/nsg/Downloads/SRR5029[]
Any ideas why is this happening or how to fix it?
Rather than using the system command to run the external program, you can use Qt's QProcess: -
or
if you don't want to wait for the process to finish. Since the functions take a QString, there's no need for the conversion to a const char*