From d06ad1b372082777c92dbc4065c0a355bc2bef93 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Sat, 13 Jul 2013 12:45:38 +0200 Subject: [PATCH 1/1] add a label to the UI --- qt/main.cpp | 6 +----- qt/multypo.cpp | 15 ++++++++++----- qt/multypo.h | 3 +++ 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/qt/main.cpp b/qt/main.cpp index f9ddee2..de96e68 100644 --- a/qt/main.cpp +++ b/qt/main.cpp @@ -1,12 +1,8 @@ #include "multypo.h" -#include +#include #include -#include -#include -#include - MultypoWindow *window; class MultypoApplication : public QApplication diff --git a/qt/multypo.cpp b/qt/multypo.cpp index 6e461e3..a5d8137 100644 --- a/qt/multypo.cpp +++ b/qt/multypo.cpp @@ -2,6 +2,8 @@ #include #include +#include +#include #include #include @@ -11,7 +13,13 @@ MultypoWindow::MultypoWindow(QWidget *parent) : QWidget(parent), xiInited(false) { - + QHBoxLayout *layout = new QHBoxLayout(this); + setLayout(layout); + + mainLabel = new QLabel(this); + layout->addWidget(mainLabel); + + setMinimumSize(300, 300); } MultypoWindow::~MultypoWindow() @@ -50,15 +58,12 @@ void MultypoWindow::showEvent ( QShowEvent * ) XISelectEvents (dpy, winId(), &eventmask, 1); xiInited = true; - - /*activateWindow(); - raise(); - setFocus(Qt::OtherFocusReason);*/ } void MultypoWindow::handleKeyPress(int device, QString string) { qDebug() << "Device" << device << "String" << string; + mainLabel->setText(QString("%1 pressed on %2").arg(string).arg(device)); } bool MultypoWindow::handleX11Event(XEvent *event) diff --git a/qt/multypo.h b/qt/multypo.h index 400d4c9..f10a5d4 100644 --- a/qt/multypo.h +++ b/qt/multypo.h @@ -3,6 +3,8 @@ #include +class QLabel; + class MultypoWindow : public QWidget { Q_OBJECT @@ -22,6 +24,7 @@ private: private: bool xiInited; int xiOpcode; + QLabel *mainLabel; }; #endif // MULTIKBD_H -- 2.30.2