QGLWidget::renderText => incomplete text
-
wrote on 24 Feb 2012, 09:16 last edited by
Hi all,
I am new to the Qt and so far I am enjoying it.
Qt version: 4.7.4Here is what I am printing on the screen:
@
qglColor(QColor("#ffffff"));
renderText(100,100,QString("Hello world!"));@Everything else (other than text) is being drawn correctly.
But only first three characters "Hel" are being printed.
Can someone point me to an area from where this problem can come from or how to solve it?Thanks,
Tomas
-
wrote on 24 Feb 2012, 10:01 last edited by
did u set the font of the text using QFont...
renderText method takes QFont as a parameter....
-
wrote on 24 Feb 2012, 10:42 last edited by
I did not. Documentation says that in case the font parameter is omitted a default one is used.
However, I have tried to set it as well, but with no effect other than font has changed.
Only first three characters are being drawn.Is there some hidden limit that could be set or something?
-
wrote on 24 Feb 2012, 12:24 last edited by
I have noticed one more thing.
Even if I use QPainter to draw text, it draws only first three chars as well.
[quote author="tomas.soltys" date="1330080141"]I did not. Documentation says that in case the font parameter is omitted a default one is used.
However, I have tried to set it as well, but with no effect other than font has changed.
Only first three characters are being drawn.Is there some hidden limit that could be set or something?[/quote]
-
wrote on 27 Feb 2012, 07:32 last edited by
Yet another observation.
This happens only on my OpenSUSE installation. On Windows 7 full string is being printed.
Tomas
-
wrote on 29 Feb 2012, 13:50 last edited by
I have created a small example. Here is the code which produces this behavior.
@#include <QtGui>
#include <QtOpenGL>#include "glwidget.h"
GLWidget::GLWidget(QWidget *parent)
: QGLWidget(QGLFormat(QGL::SampleBuffers), parent)
{
}GLWidget::~GLWidget()
{
}QSize GLWidget::minimumSizeHint() const
{
return QSize(50, 50);
}QSize GLWidget::sizeHint() const
{
return QSize(400, 400);
}void GLWidget::initializeGL()
{
qglClearColor(QColor(0,0,0,255));
}void GLWidget::resizeGL(int width, int height)
{
glViewport (0, 0, (GLsizei)width, (GLsizei)height);glLoadIdentity (); glMatrixMode (GL_PROJECTION); glLoadIdentity (); GLdouble winRatio = (GLdouble)height/(GLdouble)width; glOrtho(-1.0, 1.0, -winRatio, winRatio, -10.0, 10.0); glMatrixMode (GL_MODELVIEW);
}
void GLWidget::paintGL()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
glEnable(GL_DEPTH_TEST);this->qglColor(QColor("#ffffff")); this->renderText(0.1,0.1,0.0,QString("1Hello 1")); this->renderText(20,20,QString("2Hello 2"));
}@
-
wrote on 29 Feb 2012, 16:55 last edited by
is it working now?
1/7