Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Qt Data transfer



  • hello! I have 2 unrelated questions:

    1. Is there a way to hold the main in a wait mode?
      meaning the main will pass the return a.exec(); (a is a Qapplication) and enter a wait mode until his subprocesses will end(the gui for example).

    2. I'm streaming a video through netcat to a socket. from that socket I need to stream the data to an mplayer process.
      I've managed to do that through this code:
      void ClientVidless::run()
      {
      socket = new QTcpSocket(this);
      QStringList args1;

      args1 += "-fps";
      args1 += "60";
      args1 += "-cache";
      args1 += "1024";
      args1 += "-slave";
      args1 += "-wid";
      args1 += QString::number((int)ui->widget->winId());
      args1 += "-";

      process1 = new QProcess(0);

      process1->start("C:\Program Files (x86)\MPlayer for Windows\mplayer.exe",args1);

      qDebug() << "Connecting...";

      socket->connectToHost("192.168.1.109",5001);

      if (!socket->waitForConnected(1000))
      qDebug() << "Error:" << socket->errorString();

      connect(socket,SIGNAL(connected()),this,SLOT(connected()));
      connect(socket,SIGNAL(disconnected()),this,SLOT(disconnected()));
      connect(socket,SIGNAL(bytesWritten(qint64)),this,SLOT(bytesWritten(qint64)));
      connect(socket,SIGNAL(readyRead()),this,SLOT(readyRead()));

    }

    void ClientVidless::readyRead()
    {

    Data = socket->readAll(); //Data is a QByteArray
    
    qDebug() << " Data in: " << Data;
    
    process1->write(Data);
    

    }

    simply when ready read is emitted the socket is read and then writing to the process.
    The problem is that the video is really slow with a lot of lag.
    What is the best and fastest way in transferring data into a process?
    What is the difference between read/write to readdata/writedata functions, and how to use them(they're virtual protected)?
    Thanks for the helpers.


Log in to reply