Results 1 to 3 of 3

Thread: Conversion of QLists and Qvectors from floats to doubles

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Dec 2010
    Posts
    31
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    9
    Thanked 1 Time in 1 Post

    Default Conversion of QLists and Qvectors from floats to doubles

    Hi, this may be a simple question but i have looked arround and havent seen a direct answer. I have two situations, the first is:

    QVector<float> test // contains a series of floating point numbers

    BUT how can i convert these to QVector<double> easily. I was hoping for a simple test.toDouble() but this seems to not be the case.

    Second - a bit more complex? can i convert a QList<Qlist<float> > in a similiar manner Here is some code:


    Qt Code:
    1. QList<QList<float> > out; // create the variable discussed above
    2.  
    3. for (int i = 0; i< 10; i++) //create 10 Qlists to hold values
    4. {
    5. out << QList<float>();
    6. }
    7. for (int ii = 0; ii<10;ii++ // fill the Qlists with some values
    8. {
    9. out[ii] << somevalues[ii]
    10. }
    11.  
    12. QVector<double> test;
    13. test = out[1].toDouble // trying to take all the elements in the first Qlist of floats
    14. // and ouput them to a QVector of doubles ->DOESNT WORK
    To copy to clipboard, switch view to plain text mode 

    Hope this makes sense!

    Thanks

    Matt
    Last edited by high_flyer; 17th May 2011 at 11:39. Reason: code tags

Similar Threads

  1. QList of QLists
    By m15ch4 in forum Newbie
    Replies: 12
    Last Post: 16th October 2013, 23:36
  2. Renaming multidimensional QLists
    By mobucl in forum Newbie
    Replies: 3
    Last Post: 17th December 2010, 10:04
  3. QPainter::drawPixmap with floats ?
    By christophe.daudin in forum Qt Programming
    Replies: 8
    Last Post: 20th October 2009, 11:19
  4. help using QLists as data in QwtPlotCurve
    By esorensen in forum Qwt
    Replies: 1
    Last Post: 11th July 2008, 20:52
  5. QList of Qlists?
    By markcole in forum Qt Programming
    Replies: 6
    Last Post: 8th July 2008, 06:44

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.