Results 1 to 8 of 8

Thread: Uploading of data by using System

  1. #1
    Join Date
    Jul 2012
    Location
    Hyderabad
    Posts
    82
    Thanks
    5
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Smile Uploading of data by using System

    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......


    Qt Code:
    1. QDateTime dateTime = QDateTime::currentDateTime();
    2. QString dateTimeString = dateTime.toString("dd-MMM-yyyy");
    3.  
    4. QString s="EntryGate-";
    5.  
    6.  
    7. /////i cant have this in a string if im not wrong
    8.  
    9. ////////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
    10. system ("/home/devkermit -is /mnt/jffs2/"+s+""+dateTimeString+".xml");
    To copy to clipboard, switch view to plain text mode 



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


    Regards,

  2. #2
    Join Date
    Mar 2011
    Location
    Hyderabad, India
    Posts
    1,882
    Thanks
    3
    Thanked 452 Times in 435 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    15

    Default Re: Uploading of data by using System

    /////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?
    Qt Code:
    1. QString str = box.currentText();
    2.  
    3. QDateTime dateTime = QDateTime::currentDateTime();
    4. QString dateTimeString = dateTime.toString("dd-MMM-yyyy");
    5. QString s="EntryGate-";
    6.  
    7. system ("/home/devkermit -is /mnt/jffs2/" + s + str + dateTimeString + ".xml");
    To copy to clipboard, switch view to plain text mode 
    When you know how to do it then you may do it wrong.
    When you don't know how to do it then it is not that you may do it wrong but you may not do it right.

  3. #3
    Join Date
    Jul 2012
    Location
    Hyderabad
    Posts
    82
    Thanks
    5
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Smile Re: Uploading of data by using System

    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,

  4. #4
    Join Date
    Mar 2011
    Location
    Hyderabad, India
    Posts
    1,882
    Thanks
    3
    Thanked 452 Times in 435 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    15

    Default Re: Uploading of data by using System

    Here you go
    Qt Code:
    1. QString str = box.currentText();
    2.  
    3. QDateTime dateTime = QDateTime::currentDateTime();
    4. QString dateTimeString = dateTime.toString("dd-MMM-yyyy");
    5. QString s="EntryGate-";
    6.  
    7. const QString command = "/home/devkermit -is /mnt/jffs2/" + s + str + dateTimeString + ".xml";
    8. system(command.toStdString().c_str());
    To copy to clipboard, switch view to plain text mode 

    Please post such questions in Newbie forum
    When you know how to do it then you may do it wrong.
    When you don't know how to do it then it is not that you may do it wrong but you may not do it right.

  5. The following user says thank you to Santosh Reddy for this useful post:

    StarRocks (23rd January 2013)

  6. #5
    Join Date
    Jul 2012
    Location
    Hyderabad
    Posts
    82
    Thanks
    5
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: Uploading of data by using System

    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,

  7. #6
    Join Date
    Mar 2011
    Location
    Hyderabad, India
    Posts
    1,882
    Thanks
    3
    Thanked 452 Times in 435 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    15

    Default Re: Uploading of data by using System

    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.
    When you know how to do it then you may do it wrong.
    When you don't know how to do it then it is not that you may do it wrong but you may not do it right.

  8. #7
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Uploading of data by using System

    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.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  9. #8
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Uploading of data by using System

    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

Similar Threads

  1. Replies: 0
    Last Post: 15th April 2011, 12:03
  2. About FTP uploading and downloading
    By prats in forum Qt Programming
    Replies: 2
    Last Post: 1st March 2011, 12:28
  3. uploading files to HTTP!!
    By Raajesh in forum Qt Programming
    Replies: 2
    Last Post: 24th June 2008, 23:00
  4. system-independent C++ data types
    By magland in forum General Programming
    Replies: 15
    Last Post: 28th March 2007, 21:33
  5. QFtp : Uploading a directory
    By smshamim in forum Qt Programming
    Replies: 2
    Last Post: 31st August 2006, 13:06

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.