summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Suhren <suhren.stefan@fh-swf.de>2015-04-13 08:37:00 +0200
committerStefan Suhren <suhren.stefan@fh-swf.de>2015-04-13 08:37:00 +0200
commitb60bb2ed272972847cb533be2e86bd2d7e565918 (patch)
tree3c5c8024a55e942da90a985a5c6a24f5d63df2ff
parent80e36da2bbb4c6ce0e6f04ccff595f61769bb4ab (diff)
downloadGUI_SS2015-b60bb2ed272972847cb533be2e86bd2d7e565918.tar.gz
GUI_SS2015-b60bb2ed272972847cb533be2e86bd2d7e565918.zip
Adds tasks 2 and 3
-rw-r--r--GUI_SS2015.pro6
-rw-r--r--dlgpreferences.cpp6
-rw-r--r--interactioncanvas.cpp40
-rw-r--r--interactioncanvas.h24
-rw-r--r--mainwindow.cpp7
-rw-r--r--mainwindow.h6
-rw-r--r--mainwindow.ui36
7 files changed, 87 insertions, 38 deletions
diff --git a/GUI_SS2015.pro b/GUI_SS2015.pro
index 5bb0a3e..f6527fc 100644
--- a/GUI_SS2015.pro
+++ b/GUI_SS2015.pro
@@ -14,10 +14,12 @@ TEMPLATE = app
SOURCES += main.cpp\
mainwindow.cpp \
- dlgpreferences.cpp
+ dlgpreferences.cpp \
+ interactioncanvas.cpp
HEADERS += mainwindow.h \
- dlgpreferences.h
+ dlgpreferences.h \
+ interactioncanvas.h
FORMS += mainwindow.ui \
dlgpreferences.ui
diff --git a/dlgpreferences.cpp b/dlgpreferences.cpp
index 9174401..01e094c 100644
--- a/dlgpreferences.cpp
+++ b/dlgpreferences.cpp
@@ -7,7 +7,7 @@ DlgPreferences::DlgPreferences(QWidget *parent) :
{
ui->setupUi(this);
- QIntValidator *val = new QIntValidator(100,800,this);
+ QIntValidator *val = new QIntValidator(100, 800, this);
ui->lineEditHeight->setValidator(val);
ui->lineEditWidth->setValidator(val);
}
@@ -25,7 +25,9 @@ DlgPreferences::~DlgPreferences()
void DlgPreferences::setHeight(int arg)
{
if (m_Height == arg)
+ {
return;
+ }
m_Height = arg;
ui->lineEditHeight->setText(QString::number(m_Height));
@@ -40,7 +42,9 @@ void DlgPreferences::setHeight(int arg)
void DlgPreferences::setWidth(int arg)
{
if (m_Width == arg)
+ {
return;
+ }
m_Width = arg;
ui->lineEditWidth->setText(QString::number(m_Width));
diff --git a/interactioncanvas.cpp b/interactioncanvas.cpp
new file mode 100644
index 0000000..c289c40
--- /dev/null
+++ b/interactioncanvas.cpp
@@ -0,0 +1,40 @@
+#include "interactioncanvas.h"
+
+InteractionCanvas::InteractionCanvas()
+{
+ setFocusPolicy(Qt::StrongFocus);
+ setMouseTracking(true);
+}
+
+InteractionCanvas::~InteractionCanvas()
+{
+
+}
+
+void InteractionCanvas::mouseMoveEvent(QMouseEvent *mouseEvent)
+{
+ qDebug() << "InteractionCanvas:" << mouseEvent->pos();
+}
+
+
+void InteractionCanvas::mousePressEvent(QMouseEvent *mouseEvent)
+{
+ qDebug() << "InteractionCanvas: Mouse: pressed:" << mouseEvent->button();
+}
+
+void InteractionCanvas::mouseReleaseEvent(QMouseEvent *mouseEvent)
+{
+ qDebug() << "InteractionCanvas: Mouse: released:"<< mouseEvent->button();
+}
+
+void InteractionCanvas::keyPressEvent(QKeyEvent *keyEvent)
+{
+ qDebug() << "InteractionCanvas: Key: pressed:" << keyEvent->key() << "(" <<
+ keyEvent->text() << ")" << (keyEvent->isAutoRepeat() ? "druck" : "");
+}
+
+void InteractionCanvas::keyReleaseEvent(QKeyEvent *keyEvent)
+{
+ qDebug() << "InteractionCanvas: Key: released:" << keyEvent->key() << "(" <<
+ keyEvent->text() << ")" << (keyEvent->isAutoRepeat() ? "druck" : "");
+}
diff --git a/interactioncanvas.h b/interactioncanvas.h
new file mode 100644
index 0000000..efdf9a2
--- /dev/null
+++ b/interactioncanvas.h
@@ -0,0 +1,24 @@
+#ifndef INTERACTIONCANVAS_H
+#define INTERACTIONCANVAS_H
+
+#include <QLabel>
+#include <QDebug>
+#include <QMouseEvent>
+
+class InteractionCanvas : public QLabel
+{
+public:
+ InteractionCanvas();
+ ~InteractionCanvas();
+
+ // QWidget interface
+protected:
+ void mouseMoveEvent(QMouseEvent *mouseEvent);
+ void mousePressEvent(QMouseEvent *mouseEvent);
+ void mouseReleaseEvent(QMouseEvent *mouseEvent);
+ void keyPressEvent(QKeyEvent *keyEvent);
+ void keyReleaseEvent(QKeyEvent *keyEvent);
+
+};
+
+#endif // INTERACTIONCANVAS_H
diff --git a/mainwindow.cpp b/mainwindow.cpp
index 155bd28..5a548db 100644
--- a/mainwindow.cpp
+++ b/mainwindow.cpp
@@ -6,6 +6,7 @@ MainWindow::MainWindow(QWidget *parent) :
ui(new Ui::MainWindow)
{
ui->setupUi(this);
+ setCentralWidget(new InteractionCanvas());
}
MainWindow::~MainWindow()
@@ -41,3 +42,9 @@ void MainWindow::on_actionPreferences_triggered()
delete tmp;
}
+
+
+void MainWindow::mouseMoveEvent(QMouseEvent *mouseEvent)
+{
+ qDebug() << "MainWindow:" << mouseEvent->pos();
+}
diff --git a/mainwindow.h b/mainwindow.h
index 6f225be..410878f 100644
--- a/mainwindow.h
+++ b/mainwindow.h
@@ -3,7 +3,9 @@
#include <QMainWindow>
#include <QDebug>
+#include <QMouseEvent>
#include "dlgpreferences.h"
+#include "interactioncanvas.h"
namespace Ui {
class MainWindow;
@@ -24,6 +26,10 @@ private slots:
void on_actionPreferences_triggered();
private:
Ui::MainWindow *ui;
+
+ // QWidget interface
+protected:
+ void mouseMoveEvent(QMouseEvent *mouseEvent);
};
#endif // MAINWINDOW_H
diff --git a/mainwindow.ui b/mainwindow.ui
index 43bf0f5..8e92663 100644
--- a/mainwindow.ui
+++ b/mainwindow.ui
@@ -14,41 +14,7 @@
<string>GUIProjekt SS2015_SS</string>
</property>
<widget class="QWidget" name="centralWidget">
- <layout class="QHBoxLayout" name="horizontalLayout">
- <item>
- <spacer name="horizontalSpacer">
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>40</width>
- <height>20</height>
- </size>
- </property>
- </spacer>
- </item>
- <item>
- <widget class="QLabel" name="label">
- <property name="text">
- <string>Hello Qt World.</string>
- </property>
- </widget>
- </item>
- <item>
- <spacer name="horizontalSpacer_2">
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>40</width>
- <height>20</height>
- </size>
- </property>
- </spacer>
- </item>
- </layout>
+ <layout class="QHBoxLayout" name="horizontalLayout"/>
</widget>
<widget class="QStatusBar" name="statusBar"/>
<widget class="QMenuBar" name="menuBar">