Hi,

Please igone my previous code...

Qt Code:
  1. p.begin(myGlWidget);
  2. ...
  3. // get the width and height from the glcontext
  4. const QGLContext *glcx = myGlWidget->context();
  5. width = glcx->device()->width();
  6. height = glcx->device()->height()
  7. ...
  8. // setting some openGL state
  9. glMatrixMode(GL_PROJECTION);
  10. glLoadIdentity();
  11. glViewport(0, 0, width, height);
  12. gluProject(x, y, z, &m[0][0], &p[0][0], &v[0], &w_x, &w_y, &w_z);
  13. w_y = height - w_y;
  14. // At this point it w_x, w_y should have been in windows
  15. // co-orrdinates... but still the following line draws the text at
  16. // very top-left in glwidget, any reason ???
  17. p.drawText(QPointF(w_x, w_y), QString(text));=========== (A)
  18. p.drawLine(QRect(0, 0, width, height));================ (B)
  19. // restoring the openGL state
  20. p.end();
To copy to clipboard, switch view to plain text mode 


So here the drawLine works fine and displays the diagonal line.

But drawText displays the text at very top-left of the glwidget.
1) Is it the problem that w_x, w_y not converted into windows co-ordinate?
2) lets say glwidget width x height is 200 x 200, then suppose I want to place the text at x=4.5 and y=-1.6, then how can I convert x, y into window co-ordinates ? any steps ?

Thank you.