Commit 57112c5e by Kai Westerkamp

Added cubewidget.cpp

parent d9772752
#include "cubewidget.h"
#include <QOpenGLFunctions>
CubeWidget::CubeWidget(QWidget *parent)
: QGLWidget(QGLFormat(QGL::SampleBuffers), parent)
{
}
QSize CubeWidget::minimumSizeHint() const
{
return QSize(50, 50);
}
QSize CubeWidget::sizeHint() const
{
return QSize(600, 400);
}
void CubeWidget::initializeGL ()
{
glEnable(GL_DEPTH_TEST);
/* glEnable(GL_CULL_FACE);
glShadeModel(GL_SMOOTH);
glEnable(GL_MULTISAMPLE);
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
static GLfloat lightPosition[4] = { 0.5, 0.0, 2.0, 1.0 };
glLightfv(GL_LIGHT0, GL_POSITION, lightPosition);
*/
}
void CubeWidget::paintGL ( ) {}
void CubeWidget::resizeGL(int width , int height ) {}
void CubeWidget::mousePressEvent(QMouseEvent *event ) {}
void CubeWidget::mouseMoveEvent(QMouseEvent *event ) {}
void CubeWidget::wheelEvent(QWheelEvent *event ) {}
#ifndef CUBEWIDGET_H
#define CUBEWIDGET_H
#include <QtGui>
#include <QtOpenGL>
#include <QOpenGLFunctions>
class CubeWidget : public QGLWidget
{
protected :
void initializeGL ( ) ;
void paintGL ( ) ;
void resizeGL(int width , int height ) ;
void mousePressEvent(QMouseEvent *event ) ;
void mouseMoveEvent(QMouseEvent *event ) ;
void wheelEvent(QWheelEvent *event ) ;
public:
CubeWidget(QWidget *parent = 0);
QSize minimumSizeHint() const;
QSize sizeHint() const;
};
#endif // CUBEWIDGET_H
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
# #
#------------------------------------------------- #-------------------------------------------------
QT += core gui QT += core gui opengl
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
...@@ -12,9 +12,11 @@ TARGET = hellocube ...@@ -12,9 +12,11 @@ TARGET = hellocube
TEMPLATE = app TEMPLATE = app
SOURCES += main.cpp\ SOURCES += main.cpp\
mainwindow.cpp mainwindow.cpp \
cubewidget.cpp
HEADERS += mainwindow.h HEADERS += mainwindow.h \
cubewidget.h
RESOURCES += \ RESOURCES += \
hellocube.qrc hellocube.qrc
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject> <!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 3.5.1, 2015-10-21T15:50:15. --> <!-- Written by QtCreator 3.5.1, 2015-10-21T20:58:23. -->
<qtcreator> <qtcreator>
<data> <data>
<variable>EnvironmentId</variable> <variable>EnvironmentId</variable>
......
#include "mainwindow.h" #include "mainwindow.h"
#include <QApplication> #include <QApplication>
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
QApplication a(argc, argv); QApplication a(argc, argv);
......
...@@ -78,6 +78,11 @@ MainWindow::MainWindow(QWidget *parent) ...@@ -78,6 +78,11 @@ MainWindow::MainWindow(QWidget *parent)
statusBar->showMessage("Hello"); statusBar->showMessage("Hello");
setStatusBar(statusBar); setStatusBar(statusBar);
//Main Widget
mainWidget = new CubeWidget(this);
setCentralWidget(mainWidget);
} }
......
...@@ -11,6 +11,8 @@ ...@@ -11,6 +11,8 @@
#include <QToolBar> #include <QToolBar>
#include <QStatusBar> #include <QStatusBar>
#include <cubewidget.h>
class MainWindow : public QMainWindow class MainWindow : public QMainWindow
{ {
...@@ -36,6 +38,8 @@ private: ...@@ -36,6 +38,8 @@ private:
QToolBar *toolBar; QToolBar *toolBar;
QStatusBar *statusBar; QStatusBar *statusBar;
CubeWidget *mainWidget;
public: public:
MainWindow(QWidget *parent = 0); MainWindow(QWidget *parent = 0);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment