widgets not accepting hoverevents ?
Hi guys,
I have some widgets and QGraphicsTextItem on my scene/view. I want those items/widgets not to accept any events(especially mouse events(like hover)). I have already done this for QGraphicsTExtItem:
Code:
...
item->setAcceptsHoverEvents(false);
item->setAcceptedMouseButtons(false);
...
but do not know howto disable mousehoverEvent for widgets. My widgets are transparent and every time I move to the widget I want my special cursor to be drawn under those widgets(on the scene), but nothing on the scene is drawn(under a widget) while moving the cursor on my widgets.
Any ideas?(
Thanks
P.S>
SetDisabled(false) do not work.
setFocusPolicy(Qt::NoFocus) do not work either.
Re: widgets not accepting hoverevents ?
The only way is to install the view as event filter for the widgets and when you get any kind of mouse events for them forward them to the view. By forward I mean creating a new QMouseMoveEvent and post it in the view's event queue.
Quote:
I want my special cursor to be drawn under those widgets(on the scene),
You can't make the mouse to be displayed *under* a widget. Maybe with some serious tweaking.
Re: widgets not accepting hoverevents ?
You can also reimplement event handlers for your widgets/items and ignore() the events there. Then they will be forwarded to their parents. You can also try clearing the WA_Hover attribute for your widgets, but this might not work.
Re: widgets not accepting hoverevents ?
Code:
...
item->setAcceptedMouseButtons(false);
This cannot possibly be correct. false is anything but 0, like possibly 1, but this function takes a Qt::MouseButtons argument. I presume you meant to pass 0. ;-)
Re: widgets not accepting hoverevents ?
Hi,
Thanks for you ideas.
I do not want the "cursor to be drawn" but while I am moving the cursor there are 2 lines (1 vertical and one horicontal) drawn on the scene, and the line move while I move the cursor. When the cursor in on my widgets the lines are not redrawn, and they should be redrawn under the widget, like it happens when I move the cursor near the widgets.
I just need the widgets to ignore all mouse events, focus events, etc
Quote:
I presume you meant to pass 0. ;-)
yes, you're right.
Maverick
Re: widgets not accepting hoverevents ?
Hi,
I have solved the problem.
I have widgets and labels(on that widgets) as my information panels. To achieve transparent wigets(accepting no events, transparent for events, actions, etc.) I have set :
Code:
setMouseTracking(true);
and my widgets/and labels work as I wanted; what is needed is being drawn under those widgets and labels when I move cursor on a widget/label.
Thank you.
Maverick