<div dir="ltr">Hello, we have a QGraphicsScene that contains a qgraphicsitem that has a qgraphicsproxywidget item with controls on it like text box and label and scroll bars: <div><br></div><div>scene</div><div> object frame (item)</div><div> child 1 (item)</div><div> child 2 (item)</div><div> child 3 (proxy widget, item)</div><div> panel (qwidget)</div><div> scrollable area (qscrollablearea)</div><div> text box (qplaintext)</div><div> label (qlabel)</div><div> text box (qplaintext)<br></div><div><br></div><div>We need to prevent some of the widgets (text box etc) from capturing mouse click events because we want the object frame (item) to handle clicks to move the item based on mouse movement, show context menu, and respond to double-click to open a dialog for properties of the object. However, the scrollbars in the widget should handle mouse press/drag to move the bars and scroll the text box. </div><div><br></div><div>We implemented this by deriving a class from each widget that must ignore mouse clicks, and instantiate the derived class. For example, we have a MyTextBox class that derives from QPlainText. Each derived class does just one thing: override mousePressEvent() and contextMenuEvent() and make them ignore the event.</div><div><br></div><div>This works, but creates many derived classes just for the purpose of ignoring some events in widgets, and it is also easy to forget to create a derived class (if a new type of widget is used in the proxy) or forget to make use of an existing derived class, until client eventually reports that moving the object (item) does not work and we find out it is because we forget to use this technique. </div><div><br></div><div>Is there a better, maybe "proper" way to handle this in Qt? It would be nice to configure scene or proxy so "all click events just go to the object (item), except if the event was on a scrollbar". <br></div><div><div><br clear="all"><div><div><div dir="ltr"><div><div dir="ltr"><div dir="ltr"><div><font size="2" style="font-size:small">Oliver</font><div style="font-size:small"><font size="1">Open Source contributions: <a href="http://pubsub.sf.net/" style="color:rgb(17,85,204)" target="_blank">PyPubSub</a>,</font><span style="font-size:x-small"> </span><a href="https://github.com/schollii/nose2pytest" style="color:rgb(17,85,204);font-size:x-small" target="_blank">nose2pytest</a><span style="font-size:x-small">,</span><span style="font-size:x-small"> L</span><a href="http://lua-icxx.sf.net/" style="font-size:x-small;color:rgb(17,85,204)" target="_blank">ua-iCxx</a><span style="font-size:x-small">, </span><a href="http://iof.sf.net/" style="font-size:x-small;color:rgb(17,85,204)" target="_blank">iof</a></div><div style="font-size:small"><font size="1"><a href="http://stackoverflow.com/users/869951/schollii" style="color:rgb(17,85,204)" target="_blank">StackOverflow</a> contributions</font></div></div><div><font size="1"><br></font></div><div></div></div></div></div></div></div></div>
</div></div></div>