title: How to draw smoothly using QPainter, QOpenGLPaintDevice and QOpenGLWidget on retina display?
body: <p>The drawing is very laggy when I try to draw using <code>QWidget</code> and <code>QPainter</code>. I decided to accelerate the drawing by using <code>QOpenGLPaintDevice</code> and <code>QOpenGLWidget</code>. But the rounded corners of shapes are very rude, comparing to drawing on regular widget.</p>
  
  <p>QWidget:</p>
  
  <p><a href="https://i.stack.imgur.com/ldVRP.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ldVRP.png" alt="enter image description here"></a></p>
  
  <p>QOpenGLWidget:</p>
  
  <p><a href="https://i.stack.imgur.com/PrlAk.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/PrlAk.png" alt="enter image description here"></a></p>
  
  <p>Here is a code how I setup the QOpenGLPaintDevice.</p>
  
  <pre><code>QOpenGLPaintDevice* device = nullptr;
  
  void QOpenGLWorkspaceWidget::resizeGL(int w, int h) {
      initDeviceIfNeed();
      handleResize(this, w, h);
      int ratio = devicePixelRatio();
      device-&gt;setSize(QSize(w * ratio, h * ratio));
      device-&gt;setDevicePixelRatio(ratio);
  }
  
  void QOpenGLWorkspaceWidget::initDeviceIfNeed() {
      if (!device) {
          device = new QOpenGLPaintDevice();
          drawer-&gt;setPaintDevice(device);
      }
  }
  
  void QOpenGLWorkspaceWidget::paintGL() {
      initDeviceIfNeed();
      glDisable(GL_DEPTH_TEST);
      glClearColor(1, 1, 1, 1);
      workspaceDrawer-&gt;draw();
  }
  </code></pre>