class _RubberBand
(QtWidgets.
QWidget): def __init__(self, parent=None):
super(_RubberBand, self).__init__(parent)
self.setMouseTracking(True)
self.resize(self.window().size()) # +++ <<<-----
self.mouseMovePos = None
self._band.setGeometry(350, 0, 2, 550)
self._band_.setGeometry(0, 250, 700, 2)
self._band.show()
self._band_.show()
self.show()
def mouseMoveEvent(self, event):
a
= QtCore.
QPoint(event.
pos().
x(), self._band.
maximumHeight()) b
= QtCore.
QPoint(event.
pos().
x()+1,
2) a1
= QtCore.
QPoint(0, event.
pos().
y()) b1
= QtCore.
QPoint(self._band.
maximumWidth(), event.
pos().
y()+1) self._band.
setGeometry(QtCore.
QRect(a, b
).
normalized()) self._band_.
setGeometry(QtCore.
QRect(a1, b1
).
normalized())
self.resize(self.window().size())
self._band.update()
self._band_.update()
self.update()
class _RubberBand(QtWidgets.QWidget):
def __init__(self, parent=None):
super(_RubberBand, self).__init__(parent)
self.setMouseTracking(True)
self.resize(self.window().size()) # +++ <<<-----
self.mouseMovePos = None
self._band = QtWidgets.QRubberBand(QtWidgets.QRubberBand.Line, self)
self._band_ = QtWidgets.QRubberBand(QtWidgets.QRubberBand.Line, self)
self._band.setGeometry(350, 0, 2, 550)
self._band_.setGeometry(0, 250, 700, 2)
self._band.show()
self._band_.show()
self.show()
def mouseMoveEvent(self, event):
a = QtCore.QPoint(event.pos().x(), self._band.maximumHeight())
b = QtCore.QPoint(event.pos().x()+1, 2)
a1 = QtCore.QPoint(0, event.pos().y())
b1 = QtCore.QPoint(self._band.maximumWidth(), event.pos().y()+1)
self._band.setGeometry(QtCore.QRect(a, b).normalized())
self._band_.setGeometry(QtCore.QRect(a1, b1).normalized())
self.resize(self.window().size())
self._band.update()
self._band_.update()
self.update()
To copy to clipboard, switch view to plain text mode
Bookmarks