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. Modifying data in QByteArray
QtWS25 Last Chance

Modifying data in QByteArray

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 985 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.
  • V Offline
    V Offline
    voltron
    wrote on last edited by
    #1

    I have a QByteArray containing N float32 numbers and want to change some of this float32 values, for example, replace them with 0 or add some other value to it.

    QByteArray has replace() method which allows to replace given number of bytes with another data, but I can't figure out how to find starting index.

    For example, QByteArray contains 5 float32 numbers. If I want to replace 3rd float with value 3rd number + 12.5 I need to extract bytes related to the 3rd value, somehow convert them to float, add to the float value 12.5 and save result back into byte array.

    How I can implement this in a most efficient way?

    VRoninV 1 Reply Last reply
    0
    • V voltron

      I have a QByteArray containing N float32 numbers and want to change some of this float32 values, for example, replace them with 0 or add some other value to it.

      QByteArray has replace() method which allows to replace given number of bytes with another data, but I can't figure out how to find starting index.

      For example, QByteArray contains 5 float32 numbers. If I want to replace 3rd float with value 3rd number + 12.5 I need to extract bytes related to the 3rd value, somehow convert them to float, add to the float value 12.5 and save result back into byte array.

      How I can implement this in a most efficient way?

      VRoninV Offline
      VRoninV Offline
      VRonin
      wrote on last edited by
      #2

      @voltron said in Modifying data in QByteArray:

      I have a QByteArray containing N float32 numbers

      How are they encoded inside the QByteArray?

      "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
      ~Napoleon Bonaparte

      On a crusade to banish setIndexWidget() from the holy land of Qt

      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