PDA

View Full Version : how to combine keypress event and mousebuttonpress event?



hildebrand
26th May 2009, 21:54
Hello Everyone,
I want to know how to combine keypress event and mousebuttonpress event in QT4. My Gui Application requires a combination of ALT+leftMouseButton click and another with the right mouse button click.
Both can individually be handled with respective signals but I can't figure out how to recognise a combination of the two.
Awaiting an early reply.
Best Regards
Hildebrand

john_god
26th May 2009, 22:05
I have a sugestion, do something like this:



void class::mousePressEvent(QMouseEvent *event)
{
bool bMousepress=true;
}

void class::releaseEvent(QMouseEvent *event)
{
bool bMousepress=false;
}

void class::keyPressEvent(QKeyEvent *event)
{
if (bMousepress && Qt::Key_Alt)
{
do_something();
}

}

wysota
26th May 2009, 23:08
See QInputEvent::modifiers(). QMouseEvent inherits QInputEvent.