Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

What happened to the QGraphicsSceneMouseEvent::button() function?



  • Hi!!
    I have next code;

    void Test::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
    {
        
        qDebug()<<"MouseMove"<<event->button();
        if (event->button() != Qt::LeftButton){
              //Always execute
                  return;
        }
    QGraphicsScene::mouseMoveEvent(event);
    }
    
    Output:
    MouseMove Qt::NoButton
    

    Why does the QGraphicsSceneMouseEvent :: button () function inside the mouseMoveEvent function return Qt :: Nobutton?
    However mousePressEvent and mouseReleaseEvent function work fine :(
    Output :
    MousePress Qt::LeftButton
    MouseMove Qt::NoButton
    MouseMove Qt::NoButton
    MouseRelease Qt::LeftButton

    Thanks!!


  • Lifetime Qt Champion

    Hi,

    That surprising indeed.

    What version of Qt are you using ?
    On what platform ?
    Can you provide a minimal compilable example that reproduces this ?



  • I have:
    Qt Creator 4.9.1
    Based on Qt 5.12.3 (MSVC 2017, 32 bit)
    Built on May 26 2019 21:17:08
    From revision 168e91b618
    Copyright 2008-2019 The Qt Company Ltd. All rights reserved.

    On Windows 10 Pro and you can run "Diagram Scene Example" and executed the same code just before after mousePressEvent, mouseMoveEvent and mouseReleaseEvent, in the DiagramScene class ... I'm sorry for my bad English ;)


  • Lifetime Qt Champion

    That's the Qt Creator information. I would like to know which version of Qt you are using to build your application.


  • Lifetime Qt Champion

    Looks like the buttons method return value could be fo interest.



  • @sgaist The version is Qt opensource-windows-x86-5.13.0.


Log in to reply