Results 1 to 11 of 11

Thread: Qt Data transfer

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jul 2015
    Posts
    13
    Thanks
    8
    Qt products
    Qt5
    Platforms
    Windows

    Default 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:
    Qt Code:
    1. void ClientVidless::run()
    2. {
    3. socket = new QTcpSocket(this);
    4. QStringList args1;
    5.  
    6.  
    7. args1 += "-fps";
    8. args1 += "60";
    9. args1 += "-cache";
    10. args1 += "1024";
    11. args1 += "-slave";
    12. args1 += "-wid";
    13. args1 += QString::number((int)ui->widget->winId());
    14. args1 += "-";
    15.  
    16. process1 = new QProcess(0);
    17.  
    18. process1->start("C:\\Program Files (x86)\\MPlayer for Windows\\mplayer.exe",args1);
    19.  
    20. qDebug() << "Connecting...";
    21.  
    22. socket->connectToHost("192.168.1.109",5001);
    23.  
    24. if (!socket->waitForConnected(1000))
    25. qDebug() << "Error:" << socket->errorString();
    26.  
    27. connect(socket,SIGNAL(connected()),this,SLOT(connected()));
    28. connect(socket,SIGNAL(disconnected()),this,SLOT(disconnected()));
    29. connect(socket,SIGNAL(bytesWritten(qint64)),this,SLOT(bytesWritten(qint64)));
    30. connect(socket,SIGNAL(readyRead()),this,SLOT(readyRead()));
    31.  
    32. }
    33.  
    34.  
    35. void ClientVidless::readyRead()
    36. {
    37.  
    38. Data = socket->readAll(); //Data is a QByteArray
    39.  
    40. qDebug() << " Data in: " << Data;
    41.  
    42. process1->write(Data);
    43.  
    44. }
    To copy to clipboard, switch view to plain text mode 
    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.
    Last edited by anda_skoa; 18th July 2015 at 17:36. Reason: missing [code] tags

Similar Threads

  1. Fastest way to transfer Data over tcp
    By Qiieha in forum General Programming
    Replies: 21
    Last Post: 29th July 2012, 19:11
  2. Data transfer using TCP Socket
    By rex in forum Qt Programming
    Replies: 0
    Last Post: 24th March 2011, 17:06
  3. Data transfer between QIODevice
    By benlau in forum Qt Programming
    Replies: 0
    Last Post: 24th February 2010, 06:59
  4. Transfer Data Between Dialogs
    By umulingu in forum Qt Programming
    Replies: 4
    Last Post: 19th February 2010, 09:35

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.