Results 1 to 3 of 3

Thread: QVector<float> to QByteArray without programming

  1. #1
    Join Date
    May 2010
    Location
    Algeria
    Posts
    23
    Thanks
    5
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default QVector<float> to QByteArray without programming

    Hi;
    how to get a pointer of QVector<float> of char* type without programming.
    Thanks.
    Last edited by Naami; 23rd May 2010 at 13:08.

  2. #2
    Join Date
    May 2010
    Location
    Algeria
    Posts
    23
    Thanks
    5
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QVector<float> to char*

    ie, I need convert "QVector <float>" to "QBaytArray" for compression this data, after saving in file.

  3. #3
    Join Date
    Apr 2010
    Posts
    769
    Thanks
    1
    Thanked 94 Times in 86 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: QVector<float> to char*

    You can just take the address of the first member, assuming QVectors work like C++ vectors:

    char* c = &(myVector[0]);

    This assumes, though, that QVector behaves in such a way that doing so makes sense. It may not. If it doesn't behave itself, you'll have to loop through the array and do something similar to the above with each element.

  4. The following user says thank you to SixDegrees for this useful post:

    Naami (23rd May 2010)

Similar Threads

  1. float vs double
    By Royceybaby in forum General Programming
    Replies: 4
    Last Post: 27th January 2010, 21:55
  2. Replies: 14
    Last Post: 16th March 2009, 09:19
  3. Replies: 1
    Last Post: 10th February 2009, 09:42
  4. char to const char* with atof
    By mickey in forum General Programming
    Replies: 5
    Last Post: 29th February 2008, 04:10
  5. float
    By mickey in forum General Programming
    Replies: 5
    Last Post: 25th July 2006, 11:52

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.