Results 1 to 4 of 4

Thread: Index of two Hexvalues in QByteArray

  1. #1
    Join Date
    Mar 2011
    Posts
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Index of two Hexvalues in QByteArray

    Hello,

    How can I pick the index of two (following) Hexvalues in a QByteArray?

    Example:
    I have a QByteArray with the following Hexvalues: "ff d8 12 89 65 ff"
    When I wish the index of "d8 12", it must return: 1 or 2.
    With the index, I can use .mid to make a Substring.

    Are there any ways to do it?

    Thanks
    -Boris

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Index of two Hexvalues in QByteArray


  3. #3
    Join Date
    Mar 2011
    Posts
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Index of two Hexvalues in QByteArray

    Hello,
    Yes, I know the function of ::indexOf(), but I don't know how to put 2 following hex values into a QByteArray.
    Have the ::fromHex() Function a good performance?

    -Boris

  4. #4
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Index of two Hexvalues in QByteArray

    I don't understand. Your initial problem statement said you already have these 6 bytes in a QByteArray. You use indexOf() to find the two byte sequence you are looking for and then QByteArray::mid() to create another QByteArray containing a copy of the two bytes. Seems rather pointless given that you know what the resulting QByteArray will contain before you even start.
    Last edited by ChrisW67; 12th March 2011 at 00:41.

Similar Threads

  1. Get Row Index
    By wirasto in forum Qt Programming
    Replies: 4
    Last Post: 13th September 2009, 13:57
  2. Replies: 9
    Last Post: 25th July 2009, 13:27
  3. Index out of Range
    By santhoshv84 in forum Qt Programming
    Replies: 2
    Last Post: 19th August 2008, 15:33
  4. Value from QComboBox instead of Index
    By arunvv in forum Qt Programming
    Replies: 2
    Last Post: 17th May 2007, 22:24
  5. Get index of QValueListIterator
    By zlatko in forum Qt Programming
    Replies: 8
    Last Post: 17th February 2006, 10:27

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.