我是一名学生程序员,我正在使用 Qt 创建一个 Gui,它可以从用户那里获取输入以进行模拟。我正在尝试在 QLabel 中使用 theta 和 alpha 符号。我查看了 Qt 的 QLabel 文档 并发现 QLabel 确实支持统一码。我尝试使用这个unicode(U+0398)作为我的theta和 这个 Unicode (U+03B1) 为我的阿尔法。问题是我不确定这个 unicode 应该放在 ui 中的哪里。 Qt 对此没有说什么;所以它要么被忽视了,要么是我应该已经知道的事情。我试图将其放入文本字段中。那行不通。
这是我尝试过的最新代码:
QString alpha;
QString theta;
alpha.setUnicode(U+03B1);
theta.setUnicode(U+0398);
ui->labelExpansionAngle1->setText(alpha);
ui->labelExpansionAngle2->setText(alpha);
ui->labelOrientationAngle->setText(theta);
然后我尝试过:
ui->labelExpansionAngle1->setText("\u03B1");
ui->labelExpansionAngle2->setText("\u03B1");
ui->labelOrientationAngle->setText("\u0398");
我什至尝试使用我在此处发布的网页中的一些其他代码。我希望有人能够阐明如何将这些数据放在一起。预先感谢您的任何帮助。
I'm a student programmer and I'm using Qt to create a Gui that gets input from users for a simulation. I am trying to use the theta and alpha symbol in a QLabel. I have looked over Qt's QLabel Documentation and found that QLabel does support Unicode. I tried using this unicode(U+0398)for my theta and this Unicode (U+03B1) for my alpha. The problem is I'm not to sure where this unicode should go in the ui. Qt doesn't say anything about it; so its either overlooked or something I should have already known. I tried to put it in the text field. That didn't work.
This is the latest code I tried:
QString alpha;
QString theta;
alpha.setUnicode(U+03B1);
theta.setUnicode(U+0398);
ui->labelExpansionAngle1->setText(alpha);
ui->labelExpansionAngle2->setText(alpha);
ui->labelOrientationAngle->setText(theta);
Then I tried:
ui->labelExpansionAngle1->setText("\u03B1");
ui->labelExpansionAngle2->setText("\u03B1");
ui->labelOrientationAngle->setText("\u0398");
I even tried using some of the other codes from the web pages I posted here. I was hoping that someone could shed some light on how this data needs to be put together. Thanks in advance for any help.
发布评论
评论(3)
尝试使用:
Try with:
对于使用 PyQt5 的用户,可以通过其 构造函数:
或 setText:
如果您需要任何其他希腊字母的 unicode 字符,请查看:
https://unicode.org/charts/PDF/U0370.pdf
For those using PyQt5, you can directly set the unicode text to a
QLabel
through its constructor:or setText:
If you need the unicode characters for any other greek letter have a look at:
https://unicode.org/charts/PDF/U0370.pdf
对于在 C++ 上使用 QT 的用户,
请使用 0x 后跟 unicode 字符值。人们可以找到上面链接中 @Pablo Guerrero 提到的所有官方 unicode 字符
For those using QT on C++
Use 0x followed by unicode character value. One can find all official unicode characters as mentioned @Pablo Guerrero in the above link