ADDENDUM How to display full 4 binary bits - after QString "number" option converts string to int. including hexadecimal strings.
-
Addendum I have settled on the following ( the example is for converting MSB ) , still convoluted ,code. I would like to find out , discuss , the usage of "toLongLong" .
QString binaryNumber = QString::number(hexadecimalNumber.toLongLong(&ok, 16), 2).rightJustified(4,'0').leftJustified(8,'0');
Up front I am very sorry to reopen this post. For information, I am leaving the original post (code). I have an additions issue, I need help with to correct. This code snippet correctly converts string "42" to binary code "01000000". I do not need more help with that conversion, BUT in need help converting when the string contains hexadecimal value, such as "F9". Changing "toInt(),2)" options to toInt(),16) does not do the job. I realize that the Qt code is little convoluted and for this reason - May I suggest that only coders with experience of Qt take a look at this ? No, it is not an instruction how to reply, just a suggestion.
pFT857\_library->CAT\_Data\_String\[CAT\_Data\_Index\].mid(0,1).number(pFT857\_library->CAT\_Data\_String\[CAT\_Data\_Index\].mid(0,1).toInt(),2).leftJustified(7,'0');
Solution : pFT857_library->CAT_Data_String[CAT_Data_Index].mid(0,1).number(n,2).rightJustified(4,'0'); Output : " convert LSB to binary with leading zeroes " "0001"
I have Qt style string QString frequency = "1426000" split into another QString as
QString frequency_array = "01 42 60 00"
I need to change each pair as 8 bit binary with
MSD as upper 4 bits of the 8 bit word
AND
LSD as lower 4 bits of the 8 bit wordFor debugging purpose I like to print each step of the conversion.
As an example , I like to see "42 "
as
"01000010"I prefer Qt QString in C++ code
Here is my code so far
```
for (int index = 0; index <6 ; index++)
{
text = pFT857_library->CAT_Data_String[index];
m_ui->lineEdit_14->setText(text);
qDebug() << text;
text = text.mid(0,1).toLocal8Bit();
qDebug() << text;text = pFT857\_library->CAT\_Data\_String\[index\]; text = text.mid(1,1).toLocal8Bit(); qDebug() << text; }
```
The above WAS my initial post / code and I have dropped the post. My current code is little over-documented so I am hesitant to post it. However, I have a (simple_) question. Using the following snippet
-
Addendum I have settled on the following ( the example is for converting MSB ) , still convoluted ,code. I would like to find out , discuss , the usage of "toLongLong" .
QString binaryNumber = QString::number(hexadecimalNumber.toLongLong(&ok, 16), 2).rightJustified(4,'0').leftJustified(8,'0');
Up front I am very sorry to reopen this post. For information, I am leaving the original post (code). I have an additions issue, I need help with to correct. This code snippet correctly converts string "42" to binary code "01000000". I do not need more help with that conversion, BUT in need help converting when the string contains hexadecimal value, such as "F9". Changing "toInt(),2)" options to toInt(),16) does not do the job. I realize that the Qt code is little convoluted and for this reason - May I suggest that only coders with experience of Qt take a look at this ? No, it is not an instruction how to reply, just a suggestion.
pFT857\_library->CAT\_Data\_String\[CAT\_Data\_Index\].mid(0,1).number(pFT857\_library->CAT\_Data\_String\[CAT\_Data\_Index\].mid(0,1).toInt(),2).leftJustified(7,'0');
Solution : pFT857_library->CAT_Data_String[CAT_Data_Index].mid(0,1).number(n,2).rightJustified(4,'0'); Output : " convert LSB to binary with leading zeroes " "0001"
I have Qt style string QString frequency = "1426000" split into another QString as
QString frequency_array = "01 42 60 00"
I need to change each pair as 8 bit binary with
MSD as upper 4 bits of the 8 bit word
AND
LSD as lower 4 bits of the 8 bit wordFor debugging purpose I like to print each step of the conversion.
As an example , I like to see "42 "
as
"01000010"I prefer Qt QString in C++ code
Here is my code so far
```
for (int index = 0; index <6 ; index++)
{
text = pFT857_library->CAT_Data_String[index];
m_ui->lineEdit_14->setText(text);
qDebug() << text;
text = text.mid(0,1).toLocal8Bit();
qDebug() << text;text = pFT857\_library->CAT\_Data\_String\[index\]; text = text.mid(1,1).toLocal8Bit(); qDebug() << text; }
```
The above WAS my initial post / code and I have dropped the post. My current code is little over-documented so I am hesitant to post it. However, I have a (simple_) question. Using the following snippet
-
Addendum I have settled on the following ( the example is for converting MSB ) , still convoluted ,code. I would like to find out , discuss , the usage of "toLongLong" .
QString binaryNumber = QString::number(hexadecimalNumber.toLongLong(&ok, 16), 2).rightJustified(4,'0').leftJustified(8,'0');
Up front I am very sorry to reopen this post. For information, I am leaving the original post (code). I have an additions issue, I need help with to correct. This code snippet correctly converts string "42" to binary code "01000000". I do not need more help with that conversion, BUT in need help converting when the string contains hexadecimal value, such as "F9". Changing "toInt(),2)" options to toInt(),16) does not do the job. I realize that the Qt code is little convoluted and for this reason - May I suggest that only coders with experience of Qt take a look at this ? No, it is not an instruction how to reply, just a suggestion.
pFT857\_library->CAT\_Data\_String\[CAT\_Data\_Index\].mid(0,1).number(pFT857\_library->CAT\_Data\_String\[CAT\_Data\_Index\].mid(0,1).toInt(),2).leftJustified(7,'0');
Solution : pFT857_library->CAT_Data_String[CAT_Data_Index].mid(0,1).number(n,2).rightJustified(4,'0'); Output : " convert LSB to binary with leading zeroes " "0001"
I have Qt style string QString frequency = "1426000" split into another QString as
QString frequency_array = "01 42 60 00"
I need to change each pair as 8 bit binary with
MSD as upper 4 bits of the 8 bit word
AND
LSD as lower 4 bits of the 8 bit wordFor debugging purpose I like to print each step of the conversion.
As an example , I like to see "42 "
as
"01000010"I prefer Qt QString in C++ code
Here is my code so far
```
for (int index = 0; index <6 ; index++)
{
text = pFT857_library->CAT_Data_String[index];
m_ui->lineEdit_14->setText(text);
qDebug() << text;
text = text.mid(0,1).toLocal8Bit();
qDebug() << text;text = pFT857\_library->CAT\_Data\_String\[index\]; text = text.mid(1,1).toLocal8Bit(); qDebug() << text; }
```
The above WAS my initial post / code and I have dropped the post. My current code is little over-documented so I am hesitant to post it. However, I have a (simple_) question. Using the following snippet