QStringList ->QPointF,QSizeF Coversion???



  • Hello,

    I have QStringList now I want to convert my String list element into X co-ordinate and y co-ordinate..also want to convert into QSizeF i.e Width and height

    MAny Thanks



  • Mayby just iterate through QStringList and use QString::toFloat() method?
    Eg.:

    QStringList coordinates_list = ... //your string list
    QList <QPointF> point_list; //retrived point list
    QList <QSize> size_list; //retrived size list
    for (int i = 0; i < coordinates_list.size(); i+=2) //assuming that the list is like x,y,x,y,x,y
    {
        float x = coordinates_list.at(i).toFloat();
        float y = coordinates_list.at(i+1).toFloat();
        point_list << QPointF(x,y);
        size_list << QSize(x,y);
    }
    

Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.