-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmainwindow.cpp
More file actions
47 lines (45 loc) · 1.61 KB
/
mainwindow.cpp
File metadata and controls
47 lines (45 loc) · 1.61 KB
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
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include<QPixmap>
#include <iostream>
#include "piece.h"
#include <QDir>
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
, ui(new Ui::MainWindow)
{
ui->setupUi(this);
QPixmap myimg(":/img/board.svg");
std::cout << (QDir::currentPath()).toStdString() << std::endl;
ui->label->setPixmap(myimg.scaled(ui->label->width(),ui->label->height()));
this->setFixedSize(this->size());
for (int i = 0; i < 8;i++) {
pieces.push_back(new Piece(this, PAWN, BLACK));
}
pieces.push_back(new Piece(this, KNIGHT, BLACK));
pieces.push_back(new Piece(this, KNIGHT, BLACK));
pieces.push_back(new Piece(this, BISHOP, BLACK));
pieces.push_back(new Piece(this, BISHOP, BLACK));
pieces.push_back(new Piece(this, ROOK, BLACK));
pieces.push_back(new Piece(this, ROOK, BLACK));
pieces.push_back(new Piece(this, QUEEN, BLACK));
pieces.push_back(new Piece(this, KING, BLACK));
for (int i = 0; i < 8;i++) {
pieces.push_back(new Piece(this, PAWN, WHITE));
}
pieces.push_back(new Piece(this, KNIGHT, WHITE));
pieces.push_back(new Piece(this, KNIGHT, WHITE));
pieces.push_back(new Piece(this, BISHOP, WHITE));
pieces.push_back(new Piece(this, BISHOP, WHITE));
pieces.push_back(new Piece(this, ROOK, WHITE));
pieces.push_back(new Piece(this, ROOK, WHITE));
pieces.push_back(new Piece(this, QUEEN, WHITE));
pieces.push_back(new Piece(this, KING, WHITE));
}
MainWindow::~MainWindow()
{
for (int i = 0; i < static_cast<int>(pieces.size()); i++) {
delete pieces[i];
}
delete ui;
}