Unsolved Set pseudo-state pressed for QSplitterHandle overridden mouse events
-
I have overridden the mousePressEvent, mouseMoveEvent and mouseReleaseEvent for a sub-class QSplitterHandle and am able to change the style for the ::handle:hover but not for the ::handle:pressed. My assumption is that since I have overridden these mouse events, that I need to some how set the pseudo-state pressed to true/false within these mouse events in order for the style to be able to be changed but I haven't found a way to fix this. Does anybody know how to go about this?
-
Hi,
Are you calling the base class implementation of these methods ?
-
I'm guessing that is my question on how to do that. I have created a custom widget for the QSplitter and have overridden the createHandle to use the custom widget for the QSplitterHandle, but I am not sure how to tell it in the mouse events that the pressed is enabled or set to true.
-
How to do what ?
-
@SGaist Maybe I am confused by what you are asking. The mouse events are getting called from me clicking on the the custom QSplitter and its custom QSplitterHandle but the pseudo-state pressed needs to be set in these mouse events. Do I need to call some kind of base class method for setting the pressed state?
-
First the question will be: what are you doing in the method you reimplemented ?
-
In the mousePressEvent I have:
setCursor(Qt::ClosedHandCursor); eventPtr->accept();
In the mouseMoveEvent I have:
if (eventPtr->buttons() & Qt::LeftButton) { setCursor(Qt::ClosedHandCursor); auto pos = parentWidget()->mapFromGlobal(eventPtr->globalPos()).y(); moveSplitter(pos); eventPtr->accept(); }
and in the mouseReleaseEvent I have:
setCursor(Qt::PointingHandCursor); eventPtr->accept();
-
If you want to have QSplitter do the standard stuff beside your modifications then you have to call the base class implementation of these methods.