Tree_data. Desc//desc is a char[80] type of data
Qstring Newdescstr;
strcpy (Tree_data. Desc,
Newdescstr.tolocal8bit (). data ());
Attention:
. Tolocal8bit () in order to make qstring into Qbytearray, but also for the localization of Chinese characters;. Data () is converting Qbytearray to char*
Sometimes when you print SQL statements,. Tolocal8bit () and. Data () cannot be written in succession, and must be carried out in two steps;
Also write a function, if you often need to do so, you can call the function
Populate the content of STR with the buff
int Dbcfgfun::inputstrtobuff (char *buff, QString Str, int bufflen)
{
if (!buff | | bufflen<=0 | | Str.length () <=0)
{
return-1;
}
memset (Buff, 0, Bufflen);
int Reallen = (str.tolocal8bit (). Length () <bufflen? Str.tolocal8bit (). Length (): Bufflen);
if (reallen>0)
{
memcpy (Buff, Str.tolocal8bit (). Data (), Reallen);
}
Buff[bufflen-1] = 0;
return Reallen;
}
Assign a value (go) to the char[] array with qstring