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. Byte data type, is it data type?
Forum Updated to NodeBB v4.3 + New Features

Byte data type, is it data type?

Scheduled Pinned Locked Moved General and Desktop
6 Posts 3 Posters 19.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
    m_pahlevanzadeh
    wrote on last edited by
    #1

    Dear all,

    I'm working on port a qt project to standard C++, every Qt data type that i use F2 shortcut has a typedef in qt header files, but didn't found byte data type? what's equivalent of byte in C ?

    1 Reply Last reply
    0
    • U Offline
      U Offline
      utcenter
      wrote on last edited by
      #2

      Byte is a char, 8bits worth of 256 values

      1 Reply Last reply
      0
      • M Offline
        M Offline
        m_pahlevanzadeh
        wrote on last edited by
        #3

        unsigned char or char ?

        1 Reply Last reply
        0
        • U Offline
          U Offline
          utcenter
          wrote on last edited by
          #4

          well, a byte is a byte, 8 bits, whether it will be encoded as a signed or unsigned number. You may have noticed QByteArray has utility functions to convert the byte array to unsigned short, int, long and long long.

          I don't recall there being a QByte typedef, so a byte is... a raw byte, merely a binary representation. A byte will yield a different value depending on whether you read is as a signed or unsigned char.

          1 Reply Last reply
          0
          • M Offline
            M Offline
            m_pahlevanzadeh
            wrote on last edited by
            #5

            So, it's an unsigned char, thank you.

            1 Reply Last reply
            0
            • JeroentjehomeJ Offline
              JeroentjehomeJ Offline
              Jeroentjehome
              wrote on last edited by
              #6

              In the Windef.h file the BYTE is equal to the unsigned char. To make it cross-platform you might want to use the quint8 definition instead. Qt will make sure that it will always be 8 bits in the variable for all supported platforms.
              The BYTE will not be a big problem, but if you want to do the same for the int you might encounter strange things. A int could be a different size for any platform being 16, 32 or 64 bits wide!! Int is the default calculating variable of the platform. Using the quint16 or quint32 will make sure you always have enough bits to work with.
              When porting the Qt files to a different compiler you are able to include a "typedef.h" converting the quint8 definition etc to a standard C++ type.
              Greetz and hope this helps

              Greetz, Jeroen

              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