


這裡要選擇下面的那個中文字型。這是另外安裝的中文字型。


我修改 qt-extended-4.4.1/src/applications/textedit 使這個 textedit 可以顯示中文。
下面的程式就可以顯示中文了。
加入一個選字形的 dialog, 然後使用 QTextCodec 來做編碼的處理。
void TextEdit::newFile()
bool ok;
QFont font = QFontDialog::getFont(&ok, this);
if (ok)
{
setFont(font);
qDebug("ok");
}
else
{
qDebug("not ok");
}
QByteArray qstr="我是";
QTextCodec *codec = QTextCodec::codecForName("UTF-8");
QString string = codec->toUnicode(qstr);
editor->document()->setPlainText(string);
沒有留言:
張貼留言
使用 google 的 reCAPTCHA 驗證碼, 總算可以輕鬆留言了。
我實在受不了 spam 了, 又不想讓大家的眼睛花掉, 只好放棄匿名留言。這是沒辦法中的辦法了。留言的朋友需要有 google 帳號。