The window is followed by the mice indicator



  • Is there any way we can put it on Python so that when we press and hold the cadet on the window, it moves behind the cadet?

    If so, what libraries are to use?



  • As an option:

    import sys
    from PyQt5.QtWidgets import QApplication, QWidget, QVBoxLayout
    from PyQt5.QtCore import QPoint
    

    class MyApp(QWidget):
    def init(self):
    super().init()
    self.layout = QVBoxLayout(self)
    # ...

    !!! vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv

    def mousePressEvent(self, event):
        self.oldPos = event.globalPos()
    
    def mouseMoveEvent(self, event):
       delta = QPoint(event.globalPos() - self.oldPos)
       self.move(self.x() + delta.x(), self.y() + delta.y())
       self.oldPos = event.globalPos()
    

    !!! ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

    if name == 'main':
    app = QApplication(sys.argv)
    w = MyApp()
    w.resize(400, 300)
    w.show()
    sys.exit(app.exec_())

    введите сюда описание изображения



Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2