PDA

View Full Version : Uploading of data by using System



StarRocks
23rd January 2013, 07:23
Dear Forums,


I have a doubt regarding uploading files.......Actually what i have done is i have first listed out .xml files that are in the folder using a combobox once i select that i would be able to upload now i have a problem here please find the attachment of my code......





QDateTime dateTime = QDateTime::currentDateTime();
QString dateTimeString = dateTime.toString("dd-MMM-yyyy");

QString s="EntryGate-";


/////i cant have this in a string if im not wrong

////////what idea i need is how to have a string in system if not possible is there any way to send a file from device to pc as i have to bind that combo value in a string and then use in the system command
system ("/home/devkermit -is /mnt/jffs2/"+s+""+dateTimeString+".xml");







please let me know if any suggestion.......Any solution would be appreciable......Thanks in Advance.......


Regards,

Santosh Reddy
23rd January 2013, 07:59
/////i cant have this in a string if im not wrong
What string you can't have?


////////what idea i need is how to have a string in system if not possible is there any way to send a file from device to pc as i have to bind that combo value in a string and then use in the system command
What to you mean by "device to pc".
Where is QComboBox in the code?

Is this what you want?


QComboBox box;
QString str = box.currentText();

QDateTime dateTime = QDateTime::currentDateTime();
QString dateTimeString = dateTime.toString("dd-MMM-yyyy");
QString s="EntryGate-";

system ("/home/devkermit -is /mnt/jffs2/" + s + str + dateTimeString + ".xml");

StarRocks
23rd January 2013, 08:48
Dear Santosh,


Thanks for the reply.......Actually i jus want to know how to add how to add a string to a System command when i do so im getting the error message as "error: cannot convert 'const QString' to 'const char*' for argument '1' to 'int system(const char*)'"....Please let me know how to have a string in system so as send data from GL11 Device to pc..........Thanks in advance.....Any solution would be appreciable........


Regards,

Santosh Reddy
23rd January 2013, 09:10
Here you go


QComboBox box;
QString str = box.currentText();

QDateTime dateTime = QDateTime::currentDateTime();
QString dateTimeString = dateTime.toString("dd-MMM-yyyy");
QString s="EntryGate-";

const QString command = "/home/devkermit -is /mnt/jffs2/" + s + str + dateTimeString + ".xml";
system(command.toStdString().c_str());


Please post such questions in Newbie forum

StarRocks
23rd January 2013, 09:22
Dear Santosh,


Thanks for the reply......Actually it helped me a lot and i dont think if i post in the newbie forum will get quick response so posted here.........Thanks in Advance........Any suggestion would be appreciable.......


Regards,

Santosh Reddy
23rd January 2013, 09:42
Quick response does not depend on forum type, it depends on number of user online and how many of them are interested in answering your question.

What I mean is, asking such basic / C++ related questions in Standard Qt forum may get some rude answers, frankly I was about to be rude, then I realized your user name, and your earlier posts.

wysota
23rd January 2013, 10:40
Moving to Newbie. Next time please think whether a more appropriate title to your thread wouldn't have been "How to convert QString to const char*" rather than "Uploading of data using System". How you name your threads and how you state the problem has great influence on when you'll get help.

anda_skoa
23rd January 2013, 13:10
For invoking a local command I would probably use QString::toLocal8Bit() instead of toStdString()

However, in this case I would recommend to use QProcess instead of system.

Cheers,
Kevin