trallallero
7th October 2011, 14:35
Hi all,
I need to permit to edit only some items of the QTableWidget, not all, so I've thought to install an
event filter but I'm not able to filter the mouse events. I log the event type but I've never seen a log
with type 2, 3 or 4 (mouse events).
This is my filter:
bool CMouseEventFilter::eventFilter(QObject *Object, QEvent *Event)
{
if (Object->objectName() == "tbwHaiClients")
{
MainWindow::Log(Object->objectName() + ": " + QString().number(Event->type()));
switch (Event->type())
{
case QEvent::MouseButtonDblClick:
case QEvent::MouseButtonRelease:
case QEvent::MouseButtonPress:
{
// WILL DO SOME STUFF
//return false;
return true;
}
default: break;
}
}
return false;
}
////////////////////////////////////////////////////////////////////////////////
The filter works because I can see other event types like 1, 110, 8, 10, 11...
What am I doing wrong ?
Thanks.
Added after 17 minutes:
I've seen that if I install also:
twClients->viewport()->installEventFilter(m_MouseEventFilter);
I can see the mouse events but the problem is that I have several table widgets and all of them
have the same name in the event filter function: "qt_scrollarea_viewport".
How can I distinguish them ?
I need to permit to edit only some items of the QTableWidget, not all, so I've thought to install an
event filter but I'm not able to filter the mouse events. I log the event type but I've never seen a log
with type 2, 3 or 4 (mouse events).
This is my filter:
bool CMouseEventFilter::eventFilter(QObject *Object, QEvent *Event)
{
if (Object->objectName() == "tbwHaiClients")
{
MainWindow::Log(Object->objectName() + ": " + QString().number(Event->type()));
switch (Event->type())
{
case QEvent::MouseButtonDblClick:
case QEvent::MouseButtonRelease:
case QEvent::MouseButtonPress:
{
// WILL DO SOME STUFF
//return false;
return true;
}
default: break;
}
}
return false;
}
////////////////////////////////////////////////////////////////////////////////
The filter works because I can see other event types like 1, 110, 8, 10, 11...
What am I doing wrong ?
Thanks.
Added after 17 minutes:
I've seen that if I install also:
twClients->viewport()->installEventFilter(m_MouseEventFilter);
I can see the mouse events but the problem is that I have several table widgets and all of them
have the same name in the event filter function: "qt_scrollarea_viewport".
How can I distinguish them ?