简体   繁体   English

QGLWidget :: renderText()创建一些向下移位的字母

[英]QGLWidget::renderText() creates some downwards shifted letters

I created a class derived from QGLWidget: 我创建了一个从QGLWidget派生的类:

class OpenGLWidget : public QGLWidget

I want to write some text on top of the OpenGL widget. 我想在OpenGL小部件上写一些文本。 Therefore I used the renderText() method inside the paintGL() of my class: 因此,我在类的paintGL()中使用了renderText()方法:

QString s = QString("AaBbCcDd");
renderText(10, 20, s);        // picture line 1

In the created text on top of my widget some letters are shifted downwards / upwards. 在我的小部件顶部创建的文本中,一些字母向下/向上移动。

Have a look at this picture . 看看这张照片

For example in the first line of the picture 'C', 'G', 'O' are shifted upwards and '4', '5' are shifted downwards. 例如,在图片的第一行中,“ C”,“ G”,“ O”向上移动,而“ 4”,“ 5”向下移动。

I tried to change the font and the font size, but this only changed the letters, which are shifted, not the problem itself: 我试图更改字体和字体大小,但这仅更改了已移动的字母,而不是问题本身:

QFont font = QFont("Arial");
font.setPointSize(18);
renderText(10, 50, s, font);    // picture line 2

font = QFont("Times");
font.setPointSize(18);
renderText(10, 80, s, font);    // picture line 3

font = QFont("Courier");
font.setPointSize(18);
renderText(10, 110, s, font);   // picture line 4

font = QFont("Courier");
font.setPointSize(16);
renderText(10, 140, s, font);   // picture line 5

Does anybody know how to bring the letters on a straight line? 有人知道如何使字母成直线吗?

I also tried the QPainter::drawText() method instead of the renderText() inside the paintGL() of my class: 我还尝试了QPainter :: drawText()方法,而不是类的paintGL()中的renderText():

QPainter painter(this);
QString s = QString("AaBbCcDd");
painter.drawText(10, 20, s);

This method causes the same problem. 此方法导致相同的问题。

I am using Qt 4.7.4 with Qt Creator 2.4.1 on Mac OS 10.7. 我在Mac OS 10.7上将Qt 4.7.4与Qt Creator 2.4.1一起使用。

This is a known bug in Qt 4.8.x. 这是Qt 4.8.x中的已知错误 It affects Mac Qt-based applications that are run under OS X 10.7 and 10.8 (Lion and Mountain Lion). 它会影响在OS X 10.7和10.8(Lion和Mountain Lion)下运行的基于Mac Qt的应用程序。 If you run your application under OS X 10.6 (Snow Leopard) you will not see the problem. 如果在OS X 10.6(Snow Leopard)下运行应用程序,则不会出现此问题。

Qt 5.0.x fixes the renderText() problem for OS X 10.7 and 10.8 but is still too flaky to be used as a substitute for the more-solid 4.8.x builds. Qt 5.0.x修复了OS X 10.7和10.8的renderText()问题,但仍然过于脆弱,无法用作更可靠的4.8.x版本的替代品。

Sadly, the Qt gods have not (yet) taken it upon themselves to retrofit the 4.8.x build with the fix from the 5.0.x build. 可悲的是,Qt众神还没有考虑用5.0.x版本中的修复来改造4.8.x版本。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM