how to print variable unsigned char value in QLineEdit
-
wrote on 21 Nov 2018, 03:24 last edited by
By passing value in function i get unsigned char value in varible now i want print it in lineEdit
but when i use
ui->lineEdit_1->setText(QString::number(variable name);
it gives error as call of overloaded 'number(unsigned char[33])' is ambiguous. -
QString value(name). // name is your unsigned char string
ui->lineEdit_1.setText(value). -
wrote on 21 Nov 2018, 06:10 last edited by
Thanks @dheerendra,
In my case i dont't know the string which unsigned char hold because unsigned char get it from function and i want to print in lineEdit to see that so how can i do it? -
Thanks @dheerendra,
In my case i dont't know the string which unsigned char hold because unsigned char get it from function and i want to print in lineEdit to see that so how can i do it?@shree_121 you can simply pass
setText
the pointer to the char array, as long as it's 0 terminated it will implicitly convert it to a string.this for example works fine:
ui->lineEdit_1->setText(Q_FUNC_INFO);
-
As @J-Hilk already suggested try directly. If not give your complete sample. We will help you. Your code does not give the what you are getting.
-
wrote on 21 Nov 2018, 07:21 last edited by
@J.Hilk @dheerendra thanks, here is my program as
GTB_INFO stuGtbInfo; //from library
iRet = LNB_GTB_info(&stuGtbInfo); //library function
ui->lineEdit->setText(stuGtbInfo); //is it correct or need to define pointer separately? -
wrote on 21 Nov 2018, 07:25 last edited by
some more information..
&stuGtbInfo will return three differnt unsigned char array as stuGtbInfo.strubmodel, stuGtbInfo.strubversion, stuGtbInfo.strubrevision. -
@J.Hilk @dheerendra thanks, here is my program as
GTB_INFO stuGtbInfo; //from library
iRet = LNB_GTB_info(&stuGtbInfo); //library function
ui->lineEdit->setText(stuGtbInfo); //is it correct or need to define pointer separately?@shree_121
So it would be
ui->lineEdit->setText(stuGtbInfo.strubmodel);if strubmodel is the char *
do you want all 3 char* into one string ?
to display?like
QString model(stuGtbInfo.strubmodel);
QString version(stuGtbInfo.strubversion);
QString rev(stuGtbInfo.strubrevision);ui->lineEdit->setText( model+"|"+version+"|"+rev );
-
@mrjj
ui->lineEdit->setText(stuGtbInfo.strubmodel);
gives me error as invalid user-defined conversion from 'unsigned char[33]' to 'const QString&'
what's wrong?@shree_121
That it cant make a QString from stuGtbInfo.strubmodel.
Its unsigned char which is a bit odd for a string.
try
ui->lineEdit->setText(reinterpret_cast<const char *>((stuGtbInfo.strubmodel));
1/11