[SOLVED] Error using QByteArray



  • Hello,

    I am facing an error which i am unable to fix...

    Here what i have :

    in my .h

    QMap<qint8, qint8> patch;
    

    in my .cpp

    void matrix::updatePatch() {
       QByteArray resp = sendQuery("#VID? *\r");
       resp.remove(0, 8);
       QList<QByteArray> inouts = resp.split(',');
       patch.clear();
       for(int i = 0; i < inouts.size(); i++)
       {
           QList<QByteArray> tie = inouts.at(i).split('>');
           patch.insertMulti(QByteArray::number(tie.at(0)), QByteArray::number(tie.at(1)));
       }
    }
    

    Compiler throws me the following error :

    'operator int' is a private member of 'QByteArray'
    patch.insertMulti(QByteArray::number(tie.at(0)), QByteArray::number(tie.at(1)));
    ^~~~~~~~~

    Any help appreciated



  • QByteArray::number() takes an int and creates a QByteArray of the string equivalent of that int, but it appears you want to do the opposite; convert a QByteArray to an int.

    patch.insertMulti(tie.at(0).toInt(), tie.at(1).toInt());
    


  • SILLY ME !!!
    My bad.
    Obviously this is the way i should have done it.

    thanks a lot for having put my brain in its right place


Log in to reply
 

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