Thanks for the reply!
Yes this almost works, almost because I'm having a strange problem happening. I installed the eventFilter on the dialog like this:
//In my MainWindow
myDialog->installEventFilter(this);
...
...
{
if(obj == myDialog)
{
if(e
->type
() == QEvent::KeyPress) {
QKeyEvent* keyEvent
= static_cast<QKeyEvent
*>
(e
);
if(keyEvent->key() == Qt::Key_3)
{
process();
return true;
}
else
return false;
}
}
}
//In my MainWindow
myDialog->installEventFilter(this);
...
...
bool eventFilter(QObject *obj, QEvent *e)
{
if(obj == myDialog)
{
if(e->type() == QEvent::KeyPress)
{
QKeyEvent* keyEvent = static_cast<QKeyEvent*>(e);
if(keyEvent->key() == Qt::Key_3)
{
process();
return true;
}
else
return false;
}
}
return QMainWindow::eventFilter(obj, e);
}
To copy to clipboard, switch view to plain text mode
This will only work if I set the 'if' line :
if(keyEvent->key() == Qt::Key_Shift)
..
In other words it will only go into the if(e->type() == QEvent::KeyPress), only if with the SHIFT, Control or Alt keys are presssed but not with any other keys. And since I don't want any of the modifier keys as shortcut to my function I am still stuck.
I am on Mac OS 10.6.8 if that makes any difference..
Any ideas??
Bookmarks