How get sub partition from QBtyeArray of Hex

  • hi everyone,

    I have a hex data like below:

    this is just example, the real data is vary long

    and I want to get interval FFD8 ... FFD9 , and How I to do it .

        QString str = "4200A0DFFD8FFE000104A4649FFD900000";
        QByteArray myHexArray = QByteArray::fromHex(str.toUtf8());
        //QByteArray head = QByteArray::fromHex("FFD8");
        QByteArray head("FFD8");
        QByteArray tail = QByteArray::fromHex("FFD9");
        QByteArray realHexData;

    My goal is realHexData content is below , and it hex data
    realHexData = "FFD8FFE000104A4649FFD9";

    How can I do better?

    I just think QByteArray::indexOf, but it's not work :(

    has another one have better method for me

    thank you very much

  • Lifetime Qt Champion

  • @mrjj
    hi dear mrjj

    yes, I use the QByteArray::mid API solved my problem finally

    at first , I not get the head and tail index, but now it's can work, I can get the index

    the key point like this:

    realHexData = myHexArray.mid(ihead,itail-ihead+2);

Log in to reply