Hello
I've been trying to add a basic keyboard input handler to my mainwindow. The mainwindow has a few Qlabels and pushbuttons, nothing fancy.
I've tried adding the following code:
mainwindow.h
protected:
protected:
void keyPressEvent(QKeyEvent *event);
To copy to clipboard, switch view to plain text mode
mainwindow.cpp
void MainWindow
::keyPressEvent(QKeyEvent *event
) {
std::cout << "pressed";
}
void MainWindow::keyPressEvent(QKeyEvent *event)
{
std::cout << "pressed";
}
To copy to clipboard, switch view to plain text mode
But nothing happens when I press a key. I think there's something very simple that I'm missing, but I just can't figure it out. Trust me I've googled quite a bit on the topic but got nowhere. Any help would be greatly appreciated. Thanks.
Bookmarks