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 can I represent a char from Qt as a string of bits in binary in Qml?
Forum Updated to NodeBB v4.3 + New Features

How can I represent a char from Qt as a string of bits in binary in Qml?

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 3 Posters 1.1k 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.
  • W Offline
    W Offline
    wost
    wrote on last edited by
    #1

    I have a char type that I need to represent as a byte (string of 8 bits) in Qml. How can that be achieved?

    Currently, I have this function QString statusBinary() { return QString::number((int)_status, 2); } as a public slot and exposed to Qml (I can call the function from Qml without any errors), but the result is always 0. _status is a char, btw. Even though I can see the value is changing. What am I doing wrong?

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      What is the value of _status ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • W Offline
        W Offline
        wost
        wrote on last edited by
        #3

        I set status to a binary value like this: _status = 0b00010011, but the value is constantly changing by bitwise operations.

        1 Reply Last reply
        0
        • timdayT Offline
          timdayT Offline
          timday
          wrote on last edited by timday
          #4

          Do you emit a statusBinaryChanged(_status) when _status changes though? Else your QML won't know the C++-domain value has changed.

          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