Search code examples
qtqt5qmessagebox

QMessageBox and unicode character


I'm trying to display the bullet character in a QMessageBox, but it renders as a typical "unknown" character (a ? on a black background).

Here's how I try to do it :

QString message = QString::fromUtf8("\u2022");
QMessageBox::warning(this, "some title", message); // "this" is a QMainWindow subclass

I have tried to use the bullet character directly in source code with :

QString message = "•";

Visual Studio prompts me to save the file as Unicode, which is what I do, but the result is still the same.

I'm using Qt5.3 with Visual Studio 2010 on Windows 8.1, if that matters.


Solution

  • I would do it in the following way:

    QString message = QString("This is the bullet character: %1").arg(QChar(0x2022));