I am doing following steps;

QPainter p;
p.begin(myGlWidget);
...
// get the width and height from the glcontext
const QGLContext *glcx = myGlWidget->context();
width = glcx->device()->width();
height = glcx->device()->height()
...
// setting some openGL state
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glViewport(0, 0, width, height);
gluProject(x, y, z, &m[0][0], &p[0][0], &v[0], &w_x, &w_y, &w_z);
w_y = height - w_y;
// ??? following line does not draw text on glwidget, any reason ???
p.drawText(QPointF(w_x, w_y), QString(text)); =================== (A)
// restoring the openGL state
p.end();

Please let me know why above line (A) didn't rendered the text on glwidget.

Thank you.