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. Random crash on using renderText() of QGLWidget in Qt 5.5

Random crash on using renderText() of QGLWidget in Qt 5.5

Scheduled Pinned Locked Moved Unsolved General and Desktop
qt5.5renderingqglwidget
1 Posts 1 Posters 868 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.
  • R Offline
    R Offline
    Rashi
    wrote on 29 Oct 2015, 09:09 last edited by
    #1

    Hi All,

    I am porting code from Qt 4.8.6 to Qt 5.5. I have been able to compile the code successfully but my GUI is crashing on using renderText(x, y, z, text, font) api of QGLwidget. It was working fine on Qt 4. Following is the sample code :-

    void SBaseView::renderNodeIds(QString str)
    {
        QStringList displayStrs = str.split(" ");
        visualizerTextFont = QFont( "Arial", 11, QFont::Normal, false);
        double offsetX = 2.0;
        makeCurrent();
        glDisable(GL_DEPTH_TEST);
        glDisable(GL_LIGHTING);
        qglColor(basicFontColor);
        GLdouble projection[16], modelview[16];
        GLint viewport[4];
        GLdouble x, y, z;
        glGetIntegerv(GL_VIEWPORT, viewport);
        glGetDoublev(GL_MODELVIEW_MATRIX, modelview);
        glGetDoublev(GL_PROJECTION_MATRIX, projection);
        gluProject(position.x, position.y, position.z,
            modelview, projection, viewport, &x, &y, &z);
        glMatrixMode(GL_PROJECTION);
        glPushMatrix();
        glLoadIdentity();
        glOrtho(0, viewport[2], 0, viewport[3], -1, 1);
        glMatrixMode(GL_MODELVIEW);
        glPushMatrix();
        glLoadIdentity();
        glTranslated(x, y, z);
    
        double offsetY = 0;
        QFontMetrics fm(visualizerTextFont);
        int fontHeight = fm.height();
        offsetX += fm.width("  ");
        foreach(QString displayStr, displayStrs) {
            GLint originalAlignment = 1;
            glGetIntegerv(GL_UNPACK_ALIGNMENT, &originalAlignment);
            renderText(offsetX, -offsetY, 0, displayStr);
            glPixelStorei(GL_UNPACK_ALIGNMENT, originalAlignment);
            offsetY += fontHeight;
        }
    
        glMatrixMode(GL_PROJECTION);
        glPopMatrix();
        glMatrixMode(GL_MODELVIEW);
        glPopMatrix();
    
        glColor3ub(255, 255, 255);
        glEnable(GL_LIGHTING);
        glEnable(GL_DEPTH_TEST);
    }
    

    class SBaseView inherits QGLWidget.

    Please help.

    1 Reply Last reply
    0

    1/1

    29 Oct 2015, 09:09

    • Login

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