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. How to convert QString to QBitArray?
Forum Updated to NodeBB v4.3 + New Features

How to convert QString to QBitArray?

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 3.2k 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.
  • Z Offline
    Z Offline
    zither
    wrote on last edited by
    #1

    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

    1 Reply Last reply
    0
    • A Offline
      A Offline
      AquilaDev
      wrote on last edited by
      #2

      @
      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;
      }
      @

      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