I'd like to be able to catch the alt + click event in my custom widget, but it seems that that event is used by the top level window to be able to move the window around the desktop.
Is it possible for the top level window to ignore the alt+click event? Maybe I didn't look hard enough, but I couldn't find a solution in the documentation. Does anyone know a solution, or give a hint in what direction I should look?
The following code illustrates my problem, except for the alt modifier key all other modifier keys can be caught.
#include <QtGui>
public:
protected:
if (me->modifiers() & Qt::AltModifier) {
qDebug("Alt + click");
} else if (me->modifiers() & Qt::ControlModifier) {
qDebug("Control + click");
} else if (me->modifiers() & Qt::ShiftModifier) {
qDebug("Shift + click");
} else if (me->modifiers() & Qt::MetaModifier) {
qDebug("Meta + click");
} else {
qDebug("click");
}
}
};
int main(int argc, char **argv)
{
Widget w;
w.show();
return app.exec();
}
#include <QtGui>
class Widget : public QWidget {
public:
Widget() : QWidget(){}
protected:
void mousePressEvent(QMouseEvent *me) {
if (me->modifiers() & Qt::AltModifier) {
qDebug("Alt + click");
} else if (me->modifiers() & Qt::ControlModifier) {
qDebug("Control + click");
} else if (me->modifiers() & Qt::ShiftModifier) {
qDebug("Shift + click");
} else if (me->modifiers() & Qt::MetaModifier) {
qDebug("Meta + click");
} else {
qDebug("click");
}
}
};
int main(int argc, char **argv)
{
QApplication app(argc, argv);
Widget w;
w.show();
return app.exec();
}
To copy to clipboard, switch view to plain text mode
Bookmarks