Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QGLWidget::renderText => incomplete text

QGLWidget::renderText => incomplete text

Scheduled Pinned Locked Moved General and Desktop
7 Posts 2 Posters 4.2k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    tomas.soltys
    wrote on last edited by
    #1

    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

    1 Reply Last reply
    0
    • S Offline
      S Offline
      shoyeb
      wrote on last edited by
      #2

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

      renderText method takes QFont as a parameter....

      There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code.

      1 Reply Last reply
      0
      • T Offline
        T Offline
        tomas.soltys
        wrote on last edited by
        #3

        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?

        1 Reply Last reply
        0
        • T Offline
          T Offline
          tomas.soltys
          wrote on last edited by
          #4

          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]

          1 Reply Last reply
          0
          • T Offline
            T Offline
            tomas.soltys
            wrote on last edited by
            #5

            Yet another observation.

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

            Tomas

            1 Reply Last reply
            0
            • T Offline
              T Offline
              tomas.soltys
              wrote on last edited by
              #6

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

              }@

              1 Reply Last reply
              0
              • S Offline
                S Offline
                shoyeb
                wrote on last edited by
                #7

                is it working now?

                There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code.

                1 Reply Last reply
                0

                • Login

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • Users
                • Groups
                • Search
                • Get Qt Extensions
                • Unsolved