c++ - QFileDialog "destroys" the name of the files -


right i'm working on gui suite of console applications used bioinformatics , i'm doing first tests first project using qt. i'm using qtdesigner making gui , works except qfiledialog converts end of file name strange character, although i'm not sure if qfiledialog, or conversion qstring into const char.

here 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 says filename not correct, , after debugging, see file name goes /home/nsg/downloads/srr502947.sra /home/nsg/downloads/srr502947.sra[] , /home/nsg/downloads/srr5029[]

any ideas why happening or how fix it?

your problem calling qstring::tostdstring(), returns temporary object, , trying pointer it's contents. memory pointed becomes invalid std::string destroyed. don't need intermediate std::string @ all. should work:

qstring cmdstr =fastqdumpdir + file; system( qprintable(cmdstr) ); 

Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -