PDA

View Full Version : Why text layout eats letters when dealing with non-breakable spaces?



canopen
31st May 2017, 19:12
Test code (Qt5.5.1):


#include <QApplication>
#include <QMainWindow>
#include <QTextBrowser>

int main(int argc, char* argv[])
{
QApplication a(argc, argv);

QTextBrowser* textBrowser = new QTextBrowser();
textBrowser->setHtml("<p style=\"font-size: 50pt\">X АБ&nbsp;Y</p>");

QMainWindow w;
w.setCentralWidget(textBrowser);
w.resize(200, 200);
w.show();

return a.exec();
}

Result:
12488

How can I avoid non-ascii letters (like 'А' in test) followed by text with &nbsp; disappearing?