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. Convert QByteArray to uint8_t*(uint8_t array)
QtWS25 Last Chance

Convert QByteArray to uint8_t*(uint8_t array)

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 3 Posters 447 Views
  • 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.
  • K Offline
    K Offline
    kayakaan02
    wrote on last edited by
    #1

    How can I convert QByteArray coming from QFile::readAll() into a uint8_t array(uint8_t*)?

    J.HilkJ JonBJ 2 Replies Last reply
    0
    • K kayakaan02

      How can I convert QByteArray coming from QFile::readAll() into a uint8_t array(uint8_t*)?

      J.HilkJ Offline
      J.HilkJ Offline
      J.Hilk
      Moderators
      wrote on last edited by
      #2

      @kayakaan02
      https://doc.qt.io/qt-6/qbytearray.html#data

      just the signdness doesn't match up, but you should be able to simply cast it, as it's the same size


      Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


      Q: What's that?
      A: It's blue light.
      Q: What does it do?
      A: It turns blue.

      1 Reply Last reply
      3
      • K kayakaan02

        How can I convert QByteArray coming from QFile::readAll() into a uint8_t array(uint8_t*)?

        JonBJ Offline
        JonBJ Offline
        JonB
        wrote on last edited by
        #3

        @kayakaan02
        As @J-Hilk has said, but you might use const char *QByteArray::constData() const for efficiency/safety, assuming you really want a const uint8_t*, since I imagine you will not be altering the data.

        1 Reply Last reply
        1

        • Login

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