mirror of
https://github.com/TomHarte/CLK.git
synced 2025-02-11 15:30:52 +00:00
Adds an eventFilter, in order to steal keypresses.
This commit is contained in:
parent
235efcb2d4
commit
d62fb16a58
@ -22,6 +22,7 @@ MainWindow::MainWindow(QWidget *parent)
|
|||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
createActions();
|
createActions();
|
||||||
|
qApp->installEventFilter(this);
|
||||||
|
|
||||||
// Set up the emulation timer. Bluffer's guide: the QTimer will post an
|
// Set up the emulation timer. Bluffer's guide: the QTimer will post an
|
||||||
// event to an event loop. QThread is a thread with an event loop.
|
// event to an event loop. QThread is a thread with an event loop.
|
||||||
@ -250,3 +251,21 @@ void MainWindow::dropEvent(QDropEvent* event) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MARK: Input capture.
|
||||||
|
|
||||||
|
bool MainWindow::eventFilter(QObject *obj, QEvent *event) {
|
||||||
|
switch(event->type()) {
|
||||||
|
case QEvent::KeyPress:
|
||||||
|
case QEvent::KeyRelease: {
|
||||||
|
const auto keyEvent = static_cast<QKeyEvent *>(event);
|
||||||
|
qDebug() << keyEvent->key() << " " << (event->type() == QEvent::KeyPress);
|
||||||
|
} break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return QObject::eventFilter(obj, event);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -22,6 +22,9 @@ class MainWindow : public QMainWindow {
|
|||||||
MainWindow(QWidget *parent = nullptr);
|
MainWindow(QWidget *parent = nullptr);
|
||||||
~MainWindow();
|
~MainWindow();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool eventFilter(QObject *obj, QEvent *event) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::unique_ptr<Ui::MainWindow> ui;
|
std::unique_ptr<Ui::MainWindow> ui;
|
||||||
std::unique_ptr<QTimer> qTimer;
|
std::unique_ptr<QTimer> qTimer;
|
||||||
|
@ -10,7 +10,7 @@ ScanTargetWidget::~ScanTargetWidget() {}
|
|||||||
void ScanTargetWidget::initializeGL() {
|
void ScanTargetWidget::initializeGL() {
|
||||||
glClearColor(0.5, 0.5, 1.0, 1.0);
|
glClearColor(0.5, 0.5, 1.0, 1.0);
|
||||||
|
|
||||||
qDebug() << "share context: " << bool(context()->shareGroup());
|
// qDebug() << "share context: " << bool(context()->shareGroup());
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScanTargetWidget::paintGL() {
|
void ScanTargetWidget::paintGL() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user