title: Qt: Resize borderless widget
body: <p>My question is basically the same as <a href="https://stackoverflow.com/questions/1535826/resize-borderless-window-on-bottom-right-corner">this one</a>, but applied to the Qt C++ framework.  </p>
  
  <p>I am implementing a popup window by inheriting QWidget with flags Qt::QPopup | Qt::QWindow.  I would like this window to be moveable and resizeable, I'm currently achieving this by using the mouse events in the following code:</p>
  
  <pre><code>void TextPopup::mousePressEvent(QMouseEvent* event)
  {
      offset = event->pos();
      QWidget::mousePressEvent(event);
  }
  
  void TextPopup::mouseMoveEvent(QMouseEvent* event)
  {
      if(event->buttons() & Qt::LeftButton)
          if(resizeMode) {
              QPoint p = mapToGlobal(event->pos()) - geometry().topLeft();
              resize(p.x(), p.y());
          } else
              move(mapToParent(event->pos() - offset));
      else {
          QPoint diff = geometry().bottomRight() - mapToGlobal(event->pos());
          if(diff.x() &lt;= 6 && diff.y() &lt;= 6) {
              if(!resizeMode) {
                  setCursor(Qt::SizeFDiagCursor);
                  resizeMode = true;
              }
          } else {
              if(resizeMode) {
                  setCursor(Qt::SizeAllCursor);
                  resizeMode = false;
              }
          }
      }
  }
  
  void TextPopup::mouseReleaseEvent(QMouseEvent* event)
  {
      offset = QPoint();
      QWidget::mouseReleaseEvent(event);
  }
  </code></pre>
  
  <p>I have a few problems with this.  For one, I'm guessing there's a better way to do it.  And more importantly, I would like the resize symbol at the bottom right as in this image] (taken from the post mentioned above).  Any suggestions for achieving this?</p>
  
  <p><img src="https://i.stack.imgur.com/xuXcW.png" alt="enter image description here"></p>