I wonder what is the best and cleanest solution to write a degree symbol in a translation.
I had tr( "Snap to 90%1 angles" ).arg( QString::fromUtf8( "°" ) )
but this is not really nice.
I tried without success: tr( "Snap to 90° angles" )
I use this in a QAction: mCommonAngleAction = new QAction( tr( "Snap to 90° angles" ), menu );
Here is the result:
Do you have a good solution?
The string you want to print depends quite a lot on where you want to print it. So where do you want to print Snap to 90° angles
?
If you want to set a QLabel
text to Snap to 90° angles
a piece of code like label->setText(tr("Snap to 90° angles"));
works just fine.
If you want to print it to console it depends on the console. If the console doesn't support UTF-8
, unless you set a flag on that console to support UTF-8
characters, you're out of luck.
In a QMainWindow constructor, using the code
ui->menubar->actions().first()->setText(QObject::tr("Snap to 90° angless"));
generates:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With