QTextEdit添加内容与Qt在Vs中中文显示乱码问题解决

vs中Qt中文显示乱码解决

最简单的方法:

#pragma execution_character_set("utf-8")


QTextEdit  *m_textShower = new QTextEdit();

(1)设置字体的方法

QFonttextFont;

textFont.setPointSize(16);

m_textShower->setFont(textFont);


(2)设置编辑为只读属性的方法

m_textShower->setReadOnly(true);


(3)设置文字的方法

QTextCursorcsor = m_textShower->textCursor();

csor.movePosition(QTextCursor::Start);

csor.insertText(fileContext);


4)清除文字的方法

m_textShower->clear();


另外一种方法直接用它自身的方法append即可

m_textShower->append("你先添加的字符串")



vs中Qt中文显示乱码解决

最简单的方法:

#pragma execution_character_set("utf-8")

猜你喜欢

转载自blog.csdn.net/u011394598/article/details/80248781