-
Notifications
You must be signed in to change notification settings - Fork 0
/
mainwindow.cpp
61 lines (53 loc) · 1.83 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
50
51
52
53
54
55
56
57
58
59
60
61
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include "QVBoxLayout"
#include "QPushButton"
#include "canvas.h"
#include "QColorDialog"
#include "QLabel"
#include <iostream>
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
, ui(new Ui::MainWindow)
{
ui->setupUi(this);
//try to do test layout then replace the top thing with the actual widget we want
// Create a new widget for the layout
QWidget *centralWidget = new QWidget(this);
setCentralWidget(centralWidget);
centralWidget->setObjectName("centralWidget");
QVBoxLayout *layout = new QVBoxLayout();
//replace with the canvas
Canvas* canvas_ = new Canvas(centralWidget);
canvas_->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
canvas_->setStyleSheet("border: 2px solid green");
layout->addWidget(canvas_, 1);
QFrame* separator = new QFrame();
separator->setFrameShape(QFrame::HLine);
separator->setFrameShadow(QFrame::Sunken);
layout->addWidget(separator);
//Horizontal Tool Bar
QHBoxLayout *toolBar = new QHBoxLayout();
QPushButton* circleButton = createButton("circle");
QPushButton* lineButton = createButton("line");
QPushButton* rectangleButton = createButton("rectangle");
toolBar->addWidget(circleButton);
toolBar->addWidget(lineButton);
toolBar->addWidget(rectangleButton);
// toolBar->addWidget(new QColorDialog(this));
layout->addStretch();
layout->addLayout(toolBar);
layout->setContentsMargins(2, 2, 2, 2); // Set a 10-pixel margin around the layout
centralWidget->setStyleSheet("QWidget#centralWidget {border: 2px solid black;} "); // Set a 2-pixel thick black border around the widget
centralWidget->setLayout(layout);
}
MainWindow::~MainWindow()
{
delete ui;
}
QPushButton*
MainWindow::createButton(const QString& text, bool checkable) {
QPushButton* button = new QPushButton(text);
button->setCheckable(checkable);
return button;
}