Qt World Summit: Register Today!

Chinese Character in Qt

  • In here i just pass the string
    @@QString ItemPushButton::name_check(QString str)
    QRegExp [removed]"#([0-9]+);");
    QStringList list,list1;
    int pos = 0;
    int length;
    while((pos = expression.indexIn(str,pos))!=-1)
    list << expression.cap(1);
    QString v;
    length = expression.matchedLength();
    QByteArray ba = v.toUtf8();
    QString str1 = QString(QChar(v.toInt()));
    list1 <<str1;
    pos += expression.matchedLength();
    foreach (QString s, list) {
    str = str.replace("#","");
    str = str.replace(";","");

    foreach (QString s, list1) {
        str = str.append(s);
    return str;

    This return string is a chinese character,, I displayed this string in Qpushbutton,,In here chinese characters are displayed correctly,, But i pass this string to template and take the print means in the receipt chinese character are overwrite,,(i.e) If i pass the three chinese character means in the receipt bill it displayed 5 chinese character,,please give a suggestion,,,Thanks

  • 我还是倾向于使用Linguist翻译成中文,然后载入.qml文件进行中文的显示。

Log in to reply