Added new Project using Qt,

There is garbage left from Qt??
This commit is contained in:
Anakin 2016-12-09 15:56:45 +01:00
parent 1c5a33cfa7
commit 8cf86a41eb
9 changed files with 178 additions and 0 deletions

View File

@ -0,0 +1,29 @@
<UI version="4.0" >
<class>MainWindowClass</class>
<widget class="QMainWindow" name="MainWindowClass" >
<property name="objectName" >
<string notr="true">MainWindowClass</string>
</property>
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>600</width>
<height>400</height>
</rect>
</property>
<property name="windowTitle" >
<string>MainWindow</string>
</property>
<widget class="QMenuBar" name="menuBar" />
<widget class="QToolBar" name="mainToolBar" />
<widget class="QWidget" name="centralWidget" />
<widget class="QStatusBar" name="statusBar" />
</widget>
<layoutDefault spacing="6" margin="11" />
<pixmapfunction></pixmapfunction>
<resources>
<include location="MainWindow.qrc"/>
</resources>
<connections/>
</UI>

View File

@ -0,0 +1,21 @@
#pragma once
#include <QtWidgets/QMainWindow>
#include "ui_MainWindow.h"
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
MainWindow(QWidget *parent = Q_NULLPTR);
~MainWindow();
private:
Ui::MainWindowClass* ui;
void setupWindow();
protected:
virtual void keyPressEvent(QKeyEvent * keyEvent) override final;
};

View File

@ -0,0 +1,18 @@
#pragma once
#include <QOpenGLWidget>
#include <QOpenGLFunctions>
class OpenGlViewer : public QOpenGLWidget, protected QOpenGLFunctions
{
Q_OBJECT
public:
OpenGlViewer(QWidget *parent);
~OpenGlViewer();
protected:
virtual void initializeGL() override final;
virtual void resizeGL(int w, int h) override final;
virtual void paintGL() override final;
};

View File

@ -0,0 +1,10 @@
#pragma once
#define WINDOW_NAME "Mesh Viewer"
#define WINDOW_WIDTH 640
#define WINDOW_HEIGHT 480
#define DEFAULT_STATUS_MESSAGE "Mesh Viewer pre alpha by Anakin"
#define DEFAULT_MAJOR_VERSION 4
#define DEFAULT_MINOR_VERSION 5
#define DEAFAULT_BACKGROUND 0.5000f, 0.8000f, 1.0000f, 0.0000f

View File

@ -0,0 +1,5 @@
<RCC>
<qresource prefix="/MainWindow">
<file>icon.ico</file>
</qresource>
</RCC>

Binary file not shown.

After

Width:  |  Height:  |  Size: 264 KiB

View File

@ -0,0 +1,44 @@
#include "MainWindow.h"
#include "OpenGlViewer.h"
#include "defines.h"
#include <QKeyEvent>
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
, ui (new Ui::MainWindowClass)
{
setupWindow();
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::setupWindow()
{
ui->setupUi(this);
this->setWindowTitle(WINDOW_NAME);
this->setWindowIcon(QIcon(":/MainWindow/icon.ico"));
this->resize(WINDOW_WIDTH, WINDOW_HEIGHT);
this->setCentralWidget(new OpenGlViewer(this));
ui->statusBar->showMessage(DEFAULT_STATUS_MESSAGE);
}
void MainWindow::keyPressEvent(QKeyEvent * keyEvent)
{
switch (keyEvent->key())
{
case Qt::Key::Key_Escape:
close();
break;
}
QMainWindow::keyPressEvent(keyEvent);
}

View File

@ -0,0 +1,34 @@
#include "OpenGlViewer.h"
#include "defines.h"
OpenGlViewer::OpenGlViewer(QWidget *parent)
: QOpenGLWidget(parent)
{
QSurfaceFormat format;
format.setVersion(DEFAULT_MAJOR_VERSION, DEFAULT_MINOR_VERSION);
format.setProfile(QSurfaceFormat::CoreProfile);
this->setFormat(format);
}
OpenGlViewer::~OpenGlViewer()
{
}
void OpenGlViewer::initializeGL()
{
initializeOpenGLFunctions();
glClearColor(DEAFAULT_BACKGROUND);
}
void OpenGlViewer::resizeGL(int w, int h)
{
//TODO: change perspective
}
void OpenGlViewer::paintGL()
{
//TODO: paint here
}

17
MeshViewerQt/main.cpp Normal file
View File

@ -0,0 +1,17 @@
#include "MainWindow.h"
#include <QtWidgets/QApplication>
int startGUI(int argc, char* argv[])
{
QApplication a(argc, argv);
MainWindow w;
w.show();
return a.exec();
}
int main(int argc, char *argv[])
{
int exitstatus = startGUI(argc, argv);
return exitstatus;
}