#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QMessageBox>
#include <QPushButton>
#include <QDebug>
//#include "screen.h"
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),mainScreen(0),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
setWindowTitle("DisplayMyWindow");
CreateButton();
}
void MainWindow::buttonClicked(bool checked)
{
Q_UNUSED(checked);
if (!mainScreen) {
mainScreen = new MainScreen(this);
mainScreen ->setAttribute(Qt::WA_DeleteOnClose);
connect(mainScreen, SIGNAL(destroyed(QObject*)),this, SLOT(windowDestroyed(QObject*)));
mainScreen->showMaximized();
qDebug() << "Show Map" << mainScreen;
}
}
void MainWindow::windowDestroyed(QObject* obj)
{
disconnect(obj, SIGNAL(destroyed(QObject*)),this, SLOT(windowDestroyed(QObject*)));
qDebug() << "No Show Map" << mainScreen;
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::CreateButton()
{
QPushButton *startmapBtn = new QPushButton();
startmapBtn->setText("MapStart");
startmapBtn->setGeometry(QRect(150, 400, 135, 50));
connect(startmapBtn, SIGNAL(clicked(bool)), this, SLOT(buttonClicked(bool)));
}