How to convert QString to QBitArray?



  • Dear all,

    I would like to convert QString to QBitArray.
    eg.,
    @QString "10110"
    QBitArray 10110@

    How can I convert that?
    Parse each character and convert to int, and then assign to QBitArray?
    Is this only way?
    Any other direct conversion similar to QString.toInt?

    Thanks



  • @
    QBitArray theBitArray(yourQString.size());
    //qintx depending on the size of your QString...
    for(qint32 i; i<yourQString.size(); i++ ) {
    if (yourQString.at(i) == '0')
    theBitArray[i]=false;
    else
    theBitArray[i]=true;
    }
    @


Log in to reply
 

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