Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [SOLVED] Error using QByteArray
Forum Updated to NodeBB v4.3 + New Features

[SOLVED] Error using QByteArray

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 2.3k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Marty
    wrote on last edited by Marty
    #1

    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

    1 Reply Last reply
    0
    • M Offline
      M Offline
      mchinand
      wrote on last edited by
      #2

      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());
      
      1 Reply Last reply
      0
      • M Offline
        M Offline
        Marty
        wrote on last edited by
        #3

        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

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved