class QDockBarItemHandle(QFrame): """ A frame which provides a resize border for a QDockBarItem. """ #: A signal emitted when the handle is moved. The payload is a #: QPoint which represents the delta drag distance. handleMoved = Signal(QPoint) def __init__(self, parent=None): """ Initialize a QDockBarItemHandle. Parameters ---------- parent : QWidget, optional The parent widget of the handle. """ super(QDockBarItemHandle, self).__init__(parent) policy = QSizePolicy(QSizePolicy.Minimum, QSizePolicy.Minimum) self.setSizePolicy(policy) self._press_pos = QPoint() self._size_hint = QSize(5, 5) def sizeHint(self): """ Get the size hint for the widget. """ return self._size_hint def mousePressEvent(self, event): """ Handle the mouse press event for the widget. """ event.ignore() if event.button() == Qt.LeftButton: self._press_pos = event.pos() event.accept() def mouseReleaseEvent(self, event): """ Handle the mouse release event for the widget. """ event.ignore() if event.button() == Qt.LeftButton: self._press_pos = QPoint() event.accept() def mouseMoveEvent(self, event): """ Handle the mouse move event for the widget. """ event.ignore() if not self._press_pos.isNull(): self.handleMoved.emit(event.pos() - self._press_pos) event.accept()
class QDockBarItemHandle(QFrame): """ A frame which provides a resize border for a QDockBarItem. """ #: A signal emitted when the handle is moved. The payload is a #: QPoint which represents the delta drag distance. handleMoved = Signal(QPoint) def __init__(self, parent=None): """ Initialize a QDockBarItemHandle. Parameters ---------- parent : QWidget, optional The parent widget of the handle. """ super(QDockBarItemHandle, self).__init__(parent) policy = QSizePolicy(QSizePolicy.Minimum, QSizePolicy.Minimum) self.setSizePolicy(policy) self._press_pos = QPoint() self._size_hint = QSize(5, 5) def sizeHint(self): """ Get the size hint for the widget. """ return self._size_hint def mousePressEvent(self, event): """ Handle the mouse press event for the widget. """ event.ignore() if event.button() == Qt.LeftButton: self._press_pos = event.pos() event.accept() def mouseReleaseEvent(self, event): """ Handle the mouse release event for the widget. """ event.ignore() if event.button() == Qt.LeftButton: self._press_pos = QPoint() event.accept() def mouseMoveEvent(self, event): """ Handle the mouse move event for the widget. """ event.ignore() if not self._press_pos.isNull(): self.handleMoved.emit(event.pos() - self._press_pos) event.accept()