EventFilter Print Screen key?



  • Hey all so I've setup a simple eventfilter to run a few tests on capturing keyboard input to build a QKeySequence, here it what I have setup

    .cpp file
    @test::test(QWidget *parent) : QWidget(parent), ui(new Ui::Options)
    {
    ui->setupUi(this);
    ui->txtHotkey->installEventFilter(this);
    }

    bool test::eventFilter(QObject *obj, QEvent *event)
    {
    if (event->type() == QEvent::KeyPress)
    {
    QKeyEvent keyEvent = static_cast<QKeyEvent>(event);

        qDebug() << "key int: " << keyEvent->key();
    }
    
    return QWidget::eventFilter(obj, event);
    

    }@

    Now this works great for almost all keys however nothing happens when I press the "Print Screen" key on my keyboard why is this? as this is one of the keys I would really like to grab.



  • Hi, ~jnewing!

    Problem not in you - problem is in OS'es. They are not allowing to catch PrintScreen key press event.

    But there are a few solutions specified for systems' API's


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.