Commit 005b6880 by Kai Westerkamp

HelloCube And Menu ABr

parent 2727c924
#-------------------------------------------------
#
# Project created by QtCreator 2015-10-20T21:54:27
#
#-------------------------------------------------
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = hellocube
TEMPLATE = app
SOURCES += main.cpp\
mainwindow.cpp
HEADERS += mainwindow.h
RESOURCES += \
hellocube.qrc
<RCC>
<qresource prefix="/">
<file>img/cam_home.png</file>
<file>img/flat.png</file>
<file>img/gouraud.png</file>
<file>img/phong.png</file>
<file>img/wireframe.png</file>
</qresource>
</RCC>
#include "mainwindow.h"
#include <QApplication>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
MainWindow w;
w.show();
return a.exec();
}
#include "mainwindow.h"
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
{
setWindowTitle("Hello Cube");
menuBar = new QMenuBar();
fileMenu = new QMenu("&File");
shadingMenu= new QMenu("Shading");
exitAction = new QAction("E&xit",fileMenu);
exitAction->setShortcut(QKeySequence::Quit);
connect(exitAction, SIGNAL(triggered()), this, SLOT(close()));
shadingGroup = new QActionGroup(fileMenu);
noneAction = new QAction("None",shadingMenu);
noneAction->setShortcut(QKeySequence("Ctrl+1"));
noneAction->setCheckable(true);
shadingGroup->addAction(noneAction);
noneAction->setIcon(QIcon(":/img/wireframe.png"));
flatAction = new QAction("Flat",shadingMenu);
flatAction->setShortcut(QKeySequence("Ctrl+2"));
flatAction->setCheckable(true);
flatAction->setChecked(true);
shadingGroup->addAction(flatAction);
flatAction->setIcon(QIcon(":/img/flat.png"));
gouraudAction = new QAction("Gouraud",shadingMenu);
gouraudAction->setShortcut(QKeySequence("Ctrl+3"));
gouraudAction->setCheckable(true);
shadingGroup->addAction(gouraudAction);
gouraudAction->setIcon(QIcon(":/img/gouraud.png"));
phongAction = new QAction("Phong",shadingMenu);
phongAction->setShortcut(QKeySequence("Ctrl+4" ));
phongAction->setCheckable(true);
shadingGroup->addAction(phongAction);
phongAction->setIcon(QIcon(":/img/phong.png"));
fileMenu->addAction(exitAction);
menuBar->addMenu(fileMenu);
shadingMenu->addAction(noneAction);
shadingMenu->addAction(flatAction);
shadingMenu->addAction(gouraudAction);
shadingMenu->addAction(phongAction);
menuBar->addMenu(shadingMenu);
aboutAction = new QAction("About",menuBar);
connect(aboutAction,SIGNAL(triggered()),this,SLOT(showAboutBox()));
menuBar->addAction(aboutAction);
setMenuBar(menuBar);
}
MainWindow::~MainWindow()
{
}
void MainWindow::showAboutBox()
{
QMessageBox msgBox;
msgBox.setWindowTitle("About Hello Cube!");
msgBox.setText("Written by Kai Westerkamp");
msgBox.exec();
}
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
#include <QMenu>
#include <QMenuBar>
#include <QAction>
#include <QActionGroup>
#include <QIcon>
#include <QMessageBox>
class MainWindow : public QMainWindow
{
Q_OBJECT
private:
QMenuBar *menuBar;
QMenu *fileMenu;
QAction *exitAction;
QMenu *shadingMenu;
QActionGroup *shadingGroup;
QAction *noneAction;
QAction *flatAction;
QAction *gouraudAction;
QAction *phongAction;
QAction *aboutAction;
public:
MainWindow(QWidget *parent = 0);
~MainWindow();
public slots:
void showAboutBox();
};
#endif // MAINWINDOW_H
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