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. Am I misunderstanding or misusing QByteArray::toHex()?
Qt 6.11 is out! See what's new in the release blog

Am I misunderstanding or misusing QByteArray::toHex()?

Scheduled Pinned Locked Moved Solved General and Desktop
2 Posts 2 Posters 498 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.
  • I Offline
    I Offline
    In Fo
    wrote on last edited by
    #1

    I have a

    char[32] data;
    

    populated with some data and its bytes increment from 0x00 to 0xff one after another over the course of the algorithm. When I call

    auto hex = QByteArray(data).toHex();
    

    every time hex contains an empty array regardless of the increments of data bytes.

    What's the trick?

    1 Reply Last reply
    0
    • Chris KawaC Offline
      Chris KawaC Offline
      Chris Kawa
      Lifetime Qt Champion
      wrote on last edited by
      #2

      If first element in data is 0x00 then QByteArray(data) will be empty (it assumes a null terminated string). Pass the size as a second parameter.

      1 Reply Last reply
      5

      • Login

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