QGLWidget::renderText => incomplete text



  • Hi all,

    I am new to the Qt and so far I am enjoying it.
    Qt version: 4.7.4

    Here 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



  • did u set the font of the text using QFont...

    renderText method takes QFont as a parameter....



  • 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?



  • 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]



  • Yet another observation.

    This happens only on my OpenSUSE installation. On Windows 7 full string is being printed.

    Tomas



  • 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"));
    

    }@



  • is it working now?


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.