Must the QGLWidget::makeCurrent () be placed inside of the constructor?

such as:
Qt Code:
  1. {
  2. ......
  3. makeCurrent();
  4. ......
  5. glBegin(GL_LINES);
  6. glVertex3f(+1.0, +1.0, -1.0);
  7. ...
  8. }
To copy to clipboard, switch view to plain text mode 

I tried this:
Qt Code:
  1. QGLWidget *canvas;
  2. ...
  3. canvas->makeCurrent();
  4. ......
  5. glBegin(GL_LINES);
  6. glVertex3f(+1.0, +1.0, -1.0);
  7. ...
To copy to clipboard, switch view to plain text mode 

However, in this way, it's blank, nothing is shown on the QGLWidget.