PDA

View Full Version : widgets not accepting hoverevents ?



maverick_pol
9th October 2007, 17:23
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:


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

marcel
9th October 2007, 18:51
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.



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.

wysota
9th October 2007, 21:35
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.

Bitto
9th October 2007, 22:59
...
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. ;-)

maverick_pol
10th October 2007, 10:28
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



I presume you meant to pass 0. ;-)


yes, you're right.

Maverick

maverick_pol
10th October 2007, 14:14
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 :


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