Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

binary Representation in 8 Bits.



  • converting Q String to Binary the Final result in Debug Each byte Represented in in 4-bit (0000)
    but when append data to "Text-browser" represented in 8bits (0000 0000)
    So the same Function in debug and text Browser why it diffrent ? i want to represent in 8 bit so i can use it .
    here is the Debuger Output :

    "10101010000000111111111000000011111111010000000010000010011110"
    

    the Text-browser output in image :
    alt text

    coding :

     //Debug 
         QString s = QString("%1").arg(DataAsString.toULongLong(&ok1, 16), 8, 2, QChar('0'));
         qDebug() << "s = " <<s;
    //text brawser 
        ui->textBrowser->append("Status data received - " + QString::number(SerialbufTest.length()) + " bytes.");
         // Display bytes in debug window
         for (int i=0; i<SerialbufTest.length(); i++) {
            DataAsString = SerialbufTest[i];
             ui->textBrowser->append("Byte" + QString::number(i+1) + ":" + QString("%1").arg(DataAsString.toULongLong(&ok1, 16),8, 2, QChar('0')));
         }
    

    Thanks,


  • Lifetime Qt Champion

    Hi,

    As silly as it may sound, but in the first one you are sending everything at once while in the second case you are iterating through each value contained in that QByteArray.


  • Lifetime Qt Champion

    Hi,

    As silly as it may sound, but in the first one you are sending everything at once while in the second case you are iterating through each value contained in that QByteArray.



  • @SGaist
    Hi , Iam Sorry iam new in C++ This is stupidity from me :D
    Thank;


Log in to reply