-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmainwindow.cpp
49 lines (37 loc) · 1.59 KB
/
mainwindow.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#include "mainwindow.h"
#include "scene.h"
#include <QMenuBar>
#include <QStatusBar>
#include <QGraphicsView>
/*************************************************************************************/
/*********************** Main application window for QSimulate ***********************/
/*************************************************************************************/
/************************************ constuctor *************************************/
MainWindow::MainWindow() : QMainWindow()
{
// add drop down menus (currently empty)
QMenu*fileMenu = menuBar()->addMenu(QString("&File"));
QAction*newAction = new QAction(QString("&New"), fileMenu);
connect(newAction, SIGNAL(triggered()), this, SLOT(newGame()));
fileMenu->addAction(newAction);
QAction*exitAction = new QAction(QString("&Exit"), fileMenu);
connect(exitAction, SIGNAL(triggered()), this, SLOT(close()));
fileMenu->addAction(exitAction);//*/
}
/************************************ showMessage ************************************/
void MainWindow::showMessage( QString msg )
{
// display message on main window status bar
statusBar()->showMessage( msg );
}
void MainWindow::newGame()
{
// create scene and central widget view of scene
m_scene = new Scene(width(),height());
QGraphicsView* view = new QGraphicsView( m_scene );
view->setAlignment( Qt::AlignLeft | Qt::AlignTop );
view->setFrameStyle( 0 );
setCentralWidget( view );
// connect message signal from scene to showMessage slot
connect(m_scene, SIGNAL(message(QString)), this, SLOT(showMessage(QString)) );
}