Important: Please read the Qt Code of Conduct -


  • HI friends,

    I am rsync with Qprocess in normal function it is Working fine rsync when i run thread rsync not what is problem can any body give soultion below is my code.

    void myRunrsync()
    bool bRemote =true;
    QString pFileName = "yazmi@";
    QProcess rsync_shProcess = new QProcess();
    QStringList m_nList;
    QString m_sBandWidth ="--bwlimit="+QString::number(UPLOAD_BITRATE);
    QString m_sPassword = "yazmi2019";
    QString pDestName = "/home/yazmi/Documents/";
    m_nList<< " rsync -rP "<< pFileName << pDestName << m_sBandWidth << " -e" << " 'sshpass -p " "+m_sPassword
    +"" ssh -p "+ QString::number(DEFAULT_SSH_PORT)+"'";
    m_nList<<"rsync -rP " << pFileName << pDestName << m_sBandWidth;

       // rsync_shProcess->start("sh",QStringList()<< " rsync -rP "<< pFileName << pDestName << m_sBandWidth << " -e" << " 'sshpass  -p \" "+m_sPassword
       //                  +"\"  ssh  -p "+  QString::number(DEFAULT_SSH_PORT)+"'");
      //  rsync_shProcess->start("sh",QStringList()<<"rsync -rP " << pFileName << pDestName << m_sBandWidth);
        QString command = "rsync -rP "+pFileName+"  "+pDestName+"  "+m_sBandWidth+ " -e 'sshpass  -p \""+m_sPassword
                +"\"  ssh  -p "+  QString::number(DEFAULT_SSH_PORT)+"'";
        qDebug().noquote() << "command:" << command;


    int main(int argc, char *argv[])
    QCoreApplication a(argc, argv);


    //QFuture<void> t1 = QtConcurrent::run(myRunrsync);


    when i call function myRunrsync() it is working.
    when i run with thread QFuture<void> t1 = QtConcurrent::run(myRunrsync); it is not working what may be the problem.

  • Lifetime Qt Champion

    Why should "QFuture<void> t1 = QtConcurrent::run(myRunrsync);" work when you quit the application right afterwards?
    Why do you want to run a QProcess in a separate thread at all - it's async...

  • it is testing example in real time scenario it should be in thread multiple r sync will run so it should in different threads.

  • @satyanarayana143 said in Qprocess:

    in real time scenario it should be in thread multiple r sync will run so it should in different threads

    Not necessarily. You can create & launch multiple separate QProcess instances, all from your main thread. Each of those will obviously run the process (rsync) separately. They will all be asynchronous. So it's not evident that your code itself will need to create any threads for each QProcess.

Log in to reply