Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Disabling Wheel Event in a QGraphicsView ?
Forum Updated to NodeBB v4.3 + New Features

Disabling Wheel Event in a QGraphicsView ?

Scheduled Pinned Locked Moved Solved General and Desktop
wheeleventqgraphicsview
4 Posts 3 Posters 3.5k 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.
  • W Offline
    W Offline
    Walux
    wrote on last edited by
    #1

    Hi Qt community ,

    How to disable the wheel event in a QGraphicsView ?

    Sorry for the lazy post , and thanks for your comprehension ;)

    Taking things from beginning to end : That's my entertainment !

    Joel BodenmannJ 1 Reply Last reply
    0
    • W Walux

      Hi Qt community ,

      How to disable the wheel event in a QGraphicsView ?

      Sorry for the lazy post , and thanks for your comprehension ;)

      Joel BodenmannJ Offline
      Joel BodenmannJ Offline
      Joel Bodenmann
      wrote on last edited by Joel Bodenmann
      #2

      As there is no property to enable or disable it you have to create a subclass and overwrite the implementation of the corresponding wheelEvent(). Something along the lines of:

      class MyGraphicsView : public QGraphicsView
      {
      	Q_OBJECT
      
      public:
      	explicit MyGraphicsView(QWidget* parent = nullptr) : QGraphicsView(parent) {}
      
      protected:
      	virtual void wheelEvent(QWheelEvent* event) Q_DECL_OVERRIDE {
      		event->accept();
      	}
      };
      

      Industrial process automation software: https://simulton.com
      Embedded Graphics & GUI library: https://ugfx.io

      W 1 Reply Last reply
      1
      • Joel BodenmannJ Joel Bodenmann

        As there is no property to enable or disable it you have to create a subclass and overwrite the implementation of the corresponding wheelEvent(). Something along the lines of:

        class MyGraphicsView : public QGraphicsView
        {
        	Q_OBJECT
        
        public:
        	explicit MyGraphicsView(QWidget* parent = nullptr) : QGraphicsView(parent) {}
        
        protected:
        	virtual void wheelEvent(QWheelEvent* event) Q_DECL_OVERRIDE {
        		event->accept();
        	}
        };
        
        W Offline
        W Offline
        Walux
        wrote on last edited by Walux
        #3

        @Joel-Bodenmann

        Thanks for this unique answer .

        Actually , i figured out myself an another solution :

        void Scene::wheelEvent(QGraphicsSceneWheelEvent *event)
        {
            event->accept();
        }
        

        Probably not as good , so i'll use yours .

        topic->setAsSolved(true);

        Taking things from beginning to end : That's my entertainment !

        raven-worxR 1 Reply Last reply
        0
        • W Walux

          @Joel-Bodenmann

          Thanks for this unique answer .

          Actually , i figured out myself an another solution :

          void Scene::wheelEvent(QGraphicsSceneWheelEvent *event)
          {
              event->accept();
          }
          

          Probably not as good , so i'll use yours .

          topic->setAsSolved(true);

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

          @Walux said:

          Probably not as good , so i'll use yours .

          just for clarification:
          Actually this is exactly the same approach, just a step later.
          (After the graphics view translated and forwarded it's received events to it's scene).

          --- 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
          1

          • Login

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