title: Device-agnostic context for rendering with OpenGL in Qt
body: <p>I have some code that uses QPainter to render to a QWidget, QImage or QPrinter, since each is derived from QPaintDevice, like this:</p>
  <pre><code>void RenderWithQPainter (QPaintDevice* device)
  {
      QPainter painter (device);
      painter-&gt;doThis();
      painter-&gt;doThat();
  }
  
  void RenderToImage (QImage* image)
  {
      RenderWithQPainter (image);
  }
  
  void RenderToWidget (QWidget* widget)
  {
      RenderWithQPainter (widget);
  }
  void RenderToPrinter (QPrinter* printer)
  {
      RenderWithQPainter (printer);
  }
  </code></pre>
  <p>Now though, I want to use OpenGL.  I know how to render into a QOpelGLWidget but I'd like my code to remain device-agnostic.  So what can I render into that I can then copy to the various devices?  Is there something I could derive from each of QWidget, QImage and QPrinter, not necessarily a Qt class, which I could render to using OpenGL commands instead of QPainter?</p>