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

How to deactivate an MousepressEvent temporary ?



  • Hello I am a bit of an beginner in QT
    working with QT 5.15.0 on this project.
    So following Problem:
    I am making a chess game (the frontend) and the chesspieces are bttn *name of chesspice =new bttn

    I need this mousePressEvent to be temporarly timed out/deactivated so i can click on another chesspiece
    without triggering the mousePressEvent (the target chesspiece acting like an QGraphicsPixmarItem)

    header bttn(fell free to correct me if comments are wrong):
    class bttn:public QObject, public QGraphicsPixmapItem//creating the class bttn with properties a button needs
    {

    Q_OBJECT
    public://Public accesable functions
    void mousePressEvent(QGraphicsSceneMouseEvent *event);//creating an void mousePressEvent (working like an Interrupt)
    
    signals://signals are emmited by some functions of QT and can call a slot
    void clicked();//is an QT standart signal
    

    };

    Thanks for your help in advance.


  • Moderators

    @DerGehoernteSiegfried
    use QGraphicsItem::setAcceptedMouseButtons() to clear the accepted buttons temporarily



  • Thanks thats what I needed


Log in to reply