Results 1 to 6 of 6

Thread: The fastest way to communicate a Qvector<float> witrh Qvector<QpointF> ??

  1. #1
    Join Date
    Sep 2010
    Posts
    654
    Thanks
    56
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default The fastest way to communicate a Qvector<float> witrh Qvector<QpointF> ??

    Can anybody give me a schema to do the fastest conversion betwen

    QVector<float>
    or float []

    to-from Qvector<QPointF> ????

    Thanks

  2. #2
    Join Date
    Oct 2009
    Posts
    483
    Thanked 97 Times in 94 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: The fastest way to communicate a Qvector<float> witrh Qvector<QpointF> ??

    QPointF being essentially a pair of floating-point numbers, it is unclear what kind of conversion you want to do. Please specify it.

  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: The fastest way to communicate a Qvector<float> witrh Qvector<QpointF> ??

    Quote Originally Posted by tonnot View Post
    Can anybody give me a schema to do the fastest conversion betwen

    QVector<float>
    or float []

    to-from Qvector<QPointF> ????

    Thanks
    Qt Code:
    1. QVector<float> vf;
    2. QVector<QPointF> vp;
    3. foreach(float f, vf) {
    4. vp << QPointF(f,f); // or whatever else you want
    5. }
    To copy to clipboard, switch view to plain text mode 
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  4. #4
    Join Date
    Sep 2010
    Posts
    654
    Thanks
    56
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: The fastest way to communicate a Qvector<float> witrh Qvector<QpointF> ??

    And there is no way to do a mem copy operation ?
    The information of origin - destiny are going to be the same 10 floats >>> 5 QfointF (in example )
    Any idea ?

  5. #5
    Join Date
    Oct 2009
    Posts
    483
    Thanked 97 Times in 94 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: The fastest way to communicate a Qvector<float> witrh Qvector<QpointF> ??

    Quote Originally Posted by tonnot View Post
    And there is no way to do a mem copy operation ?
    The information of origin - destiny are going to be the same 10 floats >>> 5 QfointF (in example )
    Any idea ?
    No, you must not perform a raw memory copy. Use a loop to transform the elements as wysota suggested. I do not understand what you mean by "origin" or "destiny". Do you mean that the (2 * i)th and (2 * i + 1)th elements of the Qvector<float> should be cast to -- qreal being typedef'd to double or float depending on the architecture --, respectively, the x and y fields of the ith element of the Qvector<QPointF>?

  6. The following user says thank you to yeye_olive for this useful post:

    tonnot (3rd September 2011)

  7. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: The fastest way to communicate a Qvector<float> witrh Qvector<QpointF> ??

    Quote Originally Posted by tonnot View Post
    And there is no way to do a mem copy operation ?
    The information of origin - destiny are going to be the same 10 floats >>> 5 QfointF (in example )
    Any idea ?
    float is a POD, QPointF is a full class. You should know what the implications are.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  8. The following user says thank you to wysota for this useful post:

    tonnot (3rd September 2011)

Similar Threads

  1. QVector<float> to QByteArray without programming
    By Naami in forum Qt Programming
    Replies: 2
    Last Post: 23rd May 2010, 13:40
  2. Replies: 14
    Last Post: 16th March 2009, 09:19
  3. No repeted value in QVector
    By phillip_Qt in forum Qt Programming
    Replies: 7
    Last Post: 24th February 2009, 06:04
  4. Qvector
    By phillip_Qt in forum Qt Programming
    Replies: 3
    Last Post: 27th November 2007, 10:46
  5. QVector
    By sabeesh in forum Qt Programming
    Replies: 2
    Last Post: 17th September 2007, 14:37

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.