Results 1 to 4 of 4

Thread: Unable to start linux process by Qt

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Feb 2013
    Location
    India
    Posts
    153
    Thanks
    27
    Thanked 18 Times in 18 Posts
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Unable to start linux process by Qt

    I have chnaged my code below

    Qt Code:
    1. QScopedPointer<QProcess> my_process(new QProcess());
    2.  
    3. QString source = parent_path;
    4. source.append(QDir::separator());
    5. // source.append("*");
    6.  
    7. QString destination = map_path;
    8. destination.append(QDir::separator());
    9.  
    10. qDebug() << "Source : " << source;
    11. qDebug() << "Destination : " << destination;
    12.  
    13. QStringList arguments;
    14. arguments << "-rf"
    15. << source
    16. << destination;
    17. my_process->start("cp", arguments);
    18.  
    19. qDebug() << "Copied : " << my_process->waitForFinished();
    20. qDebug() << my_process->errorString();
    To copy to clipboard, switch view to plain text mode 

    Now it makes the data Directory in the destination directory.

    Source = "/home/DATA/"
    Destination = "/home/DATA_MAP/"

    now it creates the DATA folder in my DATA_MAP folder.
    I just want my data content in my DATA_MAP directory


    Added after 12 minutes:


    "parent_path" is the absolute path.

    //////////////////////////////////
    Following code wors for me

    Qt Code:
    1. {
    2. QDir dir(parent_path);
    3.  
    4. QStringList dirs = dir.entryList(QDir::Dirs | QDir::NoSymLinks | QDir::NoDotAndDotDot);
    5.  
    6. foreach(QString directory, dirs) {
    7. QString source = parent_path;
    8. source.append(QDir::separator());
    9. source.append(directory);
    10. qDebug() << "Source : " << source;
    11.  
    12. QString destination = map_path;
    13. destination.append(QDir::separator());
    14.  
    15. QScopedPointer<QProcess> my_process(new QProcess());
    16.  
    17. connect(this, SIGNAL(stopProcessing()), my_process.data(), SLOT(kill()), Qt::DirectConnection);
    18. QStringList arguments;
    19. arguments << "-rf"
    20. << source
    21. << destination;
    22.  
    23. my_process->start("cp", arguments);
    24.  
    25. qDebug() << "Copied : " << my_process->waitForFinished(-1);
    26. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by karankumar1609; 19th December 2013 at 11:17.
    Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.

Similar Threads

  1. QProcess : unable to start sis file
    By javed_alam786 in forum Qt for Embedded and Mobile
    Replies: 6
    Last Post: 26th August 2011, 13:42
  2. Replies: 9
    Last Post: 15th April 2011, 07:51
  3. Replies: 2
    Last Post: 14th March 2011, 20:55
  4. Replies: 5
    Last Post: 13th March 2010, 14:03
  5. The Gdb process failed to start.
    By been_1990 in forum Qt Tools
    Replies: 3
    Last Post: 29th April 2009, 17:29

Tags for this Thread

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.