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. Casting from QByteArray to const BYTE* in a function call
Forum Updated to NodeBB v4.3 + New Features

Casting from QByteArray to const BYTE* in a function call

Scheduled Pinned Locked Moved General and Desktop
5 Posts 3 Posters 6.0k 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.
  • A Offline
    A Offline
    astodolski
    wrote on last edited by
    #1

    Hi,
    This is my first post and I haven't seen if this was discussed previously. Apologies if it has and was answered.

    Using a library that I link into, I have the following signature from the header:
    virtual bool DownloadNethraBootLoader(size_t DataSize, const BYTE *Data, PercentUpdate_CB CallBackFunction=NULL, void *Context=NULL);

    I can manipulate a byte array using the Qt type QByteArray. I need to pass that to the second parameter of the function. Is there a proper conversion or cast that works. I've only been working with Qt 4.8.0 for a few weeks.

    Thanks in advance

    1 Reply Last reply
    0
    • L Offline
      L Offline
      leon.anavi
      wrote on last edited by
      #2

      Try using "QByteArray::data ()":http://developer.qt.nokia.com/doc/qt-4.8/qbytearray.html#data and after that convert char* to BYTE*.

      http://anavi.org/

      1 Reply Last reply
      0
      • A Offline
        A Offline
        astodolski
        wrote on last edited by
        #3

        Thanks Leon for the quick response. I was hoping though for a direct conversion. This may be a bit convoluted. I may be better off dealing with a array of bytes using mem functions etc. I was trying to stay within the Qt class libraries.

        1 Reply Last reply
        0
        • G Offline
          G Offline
          giesbert
          wrote on last edited by
          #4

          More direct then a getter function to access internal data of a class? Depending on the compiler you use, BYTE is a define on char or unsigned char.

          Nokia Certified Qt Specialist.
          Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

          1 Reply Last reply
          0
          • A Offline
            A Offline
            astodolski
            wrote on last edited by
            #5

            [quote author="Gerolf" date="1327146217"]More direct then a getter function to access internal data of a class? Depending on the compiler you use, BYTE is a define on char or unsigned char. [/quote]

            Yeah I suppose you're right.

            Thanks

            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