Home > Mobile >  The QGraphicsScene wheelEvent does not trigger a QGraphicsView scroll bar?
The QGraphicsScene wheelEvent does not trigger a QGraphicsView scroll bar?

Time:10-13

Custom QGraphicsScene, rewrite its wheelEvent events, to implement all the ITEM in the scene (lines, text) zoom
Internal is redrawn ITEM and reset the scene setSceneRect.

But at run time, found that the scaling operation, will trigger a QGraphicsView scroll bar, led to the scroll bar up and down or so mobile, and cause the whole scene XY position change, even if the scroll bar to hide or close, still have such a situation,

How to avoid this problem?

CodePudding user response:

 
GraphicsView - & gt; SetHorizontalScrollBarPolicy (Qt: : ScrollBarAlwaysOff);
GraphicsView - & gt; SetVerticalScrollBarPolicy (Qt: : ScrollBarAlwaysOff);

CodePudding user response:

refer to the second floor and shield the baron's reply:
 
GraphicsView - & gt; SetHorizontalScrollBarPolicy (Qt: : ScrollBarAlwaysOff);
GraphicsView - & gt; SetVerticalScrollBarPolicy (Qt: : ScrollBarAlwaysOff);


This can only be shut down the scroll bar, but can not stop the wheel events of the scene

CodePudding user response:

reference yibayan reply: 3/f
Quote: refer to the second floor and shield the baron's reply:

 
GraphicsView - & gt; SetHorizontalScrollBarPolicy (Qt: : ScrollBarAlwaysOff);
GraphicsView - & gt; SetVerticalScrollBarPolicy (Qt: : ScrollBarAlwaysOff);


This can only be shut down the scroll bar, but can not stop the wheel events of scenario

Stop the wheel events
Can override roller event functions

CodePudding user response:

reference shield, 4/f, the baron's reply:
Quote: refer to the third floor yibayan response:

Quote: refer to the second floor and shield the baron's reply:

 
GraphicsView - & gt; SetHorizontalScrollBarPolicy (Qt: : ScrollBarAlwaysOff);
GraphicsView - & gt; SetVerticalScrollBarPolicy (Qt: : ScrollBarAlwaysOff);


This can only be shut down the scroll bar, but can not stop the wheel events of scenario

Stop the wheel events
Can override wheel events function


Can set the stop signal happen
GraphicsView - & gt; HorizontalScrollBar () - & gt; BlockSignals (true);
GraphicsView - & gt; VerticalScrollBar () - & gt; BlockSignals (true);
  •  Tags:  
  • Qt
  • Related