关于Qt中收到数据用label显示的乱码问题

用特定长度的数组接收数据后用label显示,两次接收到数据(16进制)一样,但却出现了乱码,原因可能是没有找到“\0”,应给于特定长度,例 a[100]={0}; sizeof(a);

        遇见此问题解决后的代码:

    uint8_t temp[16] = {0};
    memcpy(temp, ptext->infor.name, sizeof(ptext->infor.name));//ptext为定义的结构体;
    QString sendname=codec->toUnicode((const char *)temp);
    ui->label_6->setText(sendname);

猜你喜欢

转载自blog.csdn.net/Lzh020120/article/details/79961882
今日推荐