Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Game Development
  4. How to deactivate an MousepressEvent temporary ?
Qt 6.11 is out! See what's new in the release blog

How to deactivate an MousepressEvent temporary ?

Scheduled Pinned Locked Moved Unsolved Game Development
3 Posts 2 Posters 763 Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    DerGehoernteSiegfried
    wrote on last edited by
    #1

    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.

    raven-worxR 1 Reply Last reply
    0
    • D DerGehoernteSiegfried

      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.

      raven-worxR Offline
      raven-worxR Offline
      raven-worx
      Moderators
      wrote on last edited by
      #2

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

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      1 Reply Last reply
      2
      • D Offline
        D Offline
        DerGehoernteSiegfried
        wrote on last edited by
        #3

        Thanks thats what I needed

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved