<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <div class="moz-cite-prefix">Le 25/10/18 à 19:18, Maurizio Berti a
      écrit :<br>
    </div>
    <blockquote type="cite"
cite="mid:CAPn+-XRe3Ypxeo+w6+xV9+ni3S9WUf+QkBJOcE70Xhz6-6jmyQ@mail.gmail.com">
      <meta http-equiv="content-type" content="text/html; charset=UTF-8">
      <div dir="ltr">
        <div dir="ltr">
          <div dir="ltr">The behavior is similar to QWidget's
            mouseMoveEvent ( <a
              href="http://doc.qt.io/archives/qt-4.8/qmouseevent.html#button"
              moz-do-not-send="true">http://doc.qt.io/archives/qt-4.8/qmouseevent.html#button</a>
            ):<br>
            <br>
            <blockquote class="gmail_quote" style="margin:0px 0px 0px
              0.8ex;border-left:1px solid
              rgb(204,204,204);padding-left:1ex">Note that the returned
              value is always Qt::NoButton for mouse move events</blockquote>
            <br>
          </div>
          <div>Also, as soon as a mousePressEvent is catched, Qt always
            sends a mouseMoveEvent, and for that first event only, the
            button() result is correct.</div>
          <div>You have to use buttons() instead :-)</div>
          <div><br>
          </div>
        </div>
      </div>
      <br>
      <div class="gmail_quote">
        <div dir="ltr">Il giorno gio 25 ott 2018 alle ore 10:36 Vincent
          Vande Vyvre <<a
            href="mailto:vincent.vande.vyvre@telenet.be"
            moz-do-not-send="true">vincent.vande.vyvre@telenet.be</a>>
          ha scritto:<br>
        </div>
        <blockquote class="gmail_quote" style="margin:0 0 0
          .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
          <br>
          I've a subclass QGraphicsScene with a mouseMoveEvent()
          handler.<br>
          <br>
          I need to know what button is pressed during the move but,
          strangely, <br>
          the event dont return the button.  It's always 0<br>
          <br>
          Platform
          Linux-4.15.0-38-generic-x86_64-with-Ubuntu-18.04-bionic<br>
          Qt            5.9.5<br>
          Python        3.6.6<br>
          PyQt        5.10.1<br>
          Sip            4.19.7<br>
          <br>
          Example code:<br>
---%<--------------------------------------------------------------------<br>
          # -*- coding: utf-8 -*-<br>
          import sys<br>
          from PyQt5 import QtCore, QtGui, QtWidgets<br>
          <br>
          class Main(QtWidgets.QMainWindow):<br>
               def __init__(self):<br>
                   super().__init__()<br>
                   self.resize(500, 500)<br>
                   self.viewer = QtWidgets.QGraphicsView()<br>
                   self.setCentralWidget(self.viewer)<br>
                   self.scene = Scene()<br>
                   self.viewer.setScene(self.scene)<br>
          <br>
          class Scene(QtWidgets.QGraphicsScene):<br>
               def __init__(self):<br>
                   super().__init__()<br>
                   self.setSceneRect(0.0, 0.0, 450.0, 450.0)<br>
          <br>
               def mouseMoveEvent(self, event):<br>
                   print(event, "button: ", event.button())<br>
          <br>
          if __name__ == "__main__":<br>
               app = QtWidgets.QApplication([])<br>
               main = Main()<br>
               main.show()<br>
               sys.exit(app.exec_())<br>
---%<--------------------------------------------------------------------<br>
          <br>
          <br>
          Thanks,<br>
          <br>
          Vincent<br>
          <br>
          _______________________________________________<br>
          PyQt mailing list    <a
            href="mailto:PyQt@riverbankcomputing.com" target="_blank"
            moz-do-not-send="true">PyQt@riverbankcomputing.com</a><br>
          <a
            href="https://www.riverbankcomputing.com/mailman/listinfo/pyqt"
            rel="noreferrer" target="_blank" moz-do-not-send="true">https://www.riverbankcomputing.com/mailman/listinfo/pyqt</a></blockquote>
      </div>
      <br clear="all">
      <div><br>
      </div>
      -- <br>
      <div dir="ltr" class="gmail_signature"
        data-smartmail="gmail_signature">È difficile avere una
        convinzione precisa quando si parla delle ragioni del cuore. -
        "Sostiene Pereira", Antonio Tabucchi<br>
        <a href="http://www.jidesk.net" target="_blank"
          moz-do-not-send="true">http://www.jidesk.net</a></div>
    </blockquote>
    <p>Thanks Maurizio for the explanation, that's works with buttons()</p>
    <p>Vincent<br>
    </p>
  </body>
</html>