Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Qprocess

Qprocess

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 3 Posters 331 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    satyanarayana143
    wrote on last edited by
    #1

    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@192.168.0.103:/home/yazmi/YazmiFileRepository/FiletoTransmit/Test222.pdf";
    QProcess rsync_shProcess = new QProcess();
    if(!pFileName.isNull())
    {
    QStringList m_nList;
    QString m_sBandWidth ="--bwlimit="+QString::number(UPLOAD_BITRATE);
    QString m_sPassword = "yazmi2019";
    QString pDestName = "/home/yazmi/Documents/";
    /
    if(bRemote)
    {
    m_nList<< " rsync -rP "<< pFileName << pDestName << m_sBandWidth << " -e" << " 'sshpass -p " "+m_sPassword
    +"" ssh -p "+ QString::number(DEFAULT_SSH_PORT)+"'";
    }
    else
    {
    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);
    
    
        rsync_shProcess->start("sh");
    
        rsync_shProcess->setProcessChannelMode(QProcess::MergedChannels);
    
        QString command = "rsync -rP "+pFileName+"  "+pDestName+"  "+m_sBandWidth+ " -e 'sshpass  -p \""+m_sPassword
                +"\"  ssh  -p "+  QString::number(DEFAULT_SSH_PORT)+"'";
    
    
        qDebug().noquote() << "command:" << command;
    
        //rsync_shProcess->start(command);
    
    
       rsync_shProcess->write(command.toStdString().c_str());
    
       rsync_shProcess->closeWriteChannel();
    
    }
    

    }

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

    myRunrsync();

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

    1 Reply Last reply
    0
    • Christian EhrlicherC Online
      Christian EhrlicherC Online
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

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

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      1 Reply Last reply
      3
      • S Offline
        S Offline
        satyanarayana143
        wrote on last edited by
        #3

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

        JonBJ 1 Reply Last reply
        0
        • S satyanarayana143

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

          JonBJ Offline
          JonBJ Offline
          JonB
          wrote on last edited by
          #4

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

          1 Reply Last reply
          3

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved