Results 1 to 11 of 11

Thread: Qt Data transfer

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts

    Default Re: Qt Data transfer

    Quote Originally Posted by d_stranz View Post
    If you want to dynamically allocate the buffer, then you should use QAbstractSocket::bytesAvailable() to find out what is waiting, then allocate your array to that size before calling read().
    Sure, but dynamically allocating memory is what we are trying to avoid here :-)
    If that would be OK the easiest way would be to use use the original code.

    Quote Originally Posted by Shibby284 View Post
    1+2. Data = new char(0); is this good?what is the optimal size ,if there is such a thing, in defining the buffer? is leaving it zero is ok?
    As already mentioned, this allocates a single char.

    Qt Code:
    1. char *buffer = new char[1024]; // allocate 124 chars
    To copy to clipboard, switch view to plain text mode 
    or simply have a QByteArray member in your class and either initialize it with the buffer size or call reserve() with the buffer size.
    Nice side effect of this is that you don't have to take care about deleting the memory later on.

    Cheers,
    _

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Wiki edits
    17

    Default Re: Qt Data transfer

    Dumb question, is your program doing anything to the data coming from netcat before you send it to mplayer?

Similar Threads

  1. Fastest way to transfer Data over tcp
    By Qiieha in forum General Programming
    Replies: 21
    Last Post: 29th July 2012, 18:11
  2. Data transfer using TCP Socket
    By rex in forum Qt Programming
    Replies: 0
    Last Post: 24th March 2011, 16:06
  3. Data transfer between QIODevice
    By benlau in forum Qt Programming
    Replies: 0
    Last Post: 24th February 2010, 05:59
  4. Transfer Data Between Dialogs
    By umulingu in forum Qt Programming
    Replies: 4
    Last Post: 19th February 2010, 08: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
  •  
Qt is a trademark of The Qt Company.