Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
how to print variable unsigned char value in QLineEdit
By passing value in function i get unsigned char value in varible now i want print it in lineEdit
but when i use
it gives error as call of overloaded 'number(unsigned char)' is ambiguous.
QString value(name). // name is your unsigned char string
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
setTextthe 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:
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.
@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?
some more information..
&stuGtbInfo will return three differnt unsigned char array as stuGtbInfo.strubmodel, stuGtbInfo.strubversion, stuGtbInfo.strubrevision.
So it would be
if strubmodel is the char *
do you want all 3 char* into one string ?
ui->lineEdit->setText( model+"|"+version+"|"+rev );
gives me error as invalid user-defined conversion from 'unsigned char' to 'const QString&'
That it cant make a QString from stuGtbInfo.strubmodel.
Its unsigned char which is a bit odd for a string.
ui->lineEdit->setText(reinterpret_cast<const char *>((stuGtbInfo.strubmodel));
@mrjj thanks a lott..it worked for me.