Commit 8cf86a41 authored by Anakin's avatar Anakin

Added new Project using Qt,

There is garbage left from Qt??
parent 1c5a33cf
<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>
#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;
};
#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;
};
#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
<RCC>
<qresource prefix="/MainWindow">
<file>icon.ico</file>
</qresource>
</RCC>
#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);
}
#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
}
#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;
}
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