-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmainwindow.cpp
More file actions
39 lines (33 loc) · 810 Bytes
/
Copy pathmainwindow.cpp
File metadata and controls
39 lines (33 loc) · 810 Bytes
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
#include <QTabBar>
#include <QToolButton>
#include <QIcon>
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include "tab.h"
#ifdef QT_DEBUG
#include <QDebug>
#endif
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
ui->toolBar->addAction(QIcon(":/icons/add.png"), "New Tab", [this] () {
addTab();
})->setShortcut(tr("ctrl+n"));
addTab();
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::addTab()
{
ui->tabWidget->addTab(new Tab(this), "Tab " + QString::number(ui->tabWidget->count() + 1));
ui->tabWidget->setTabsClosable(true);
connect(ui->tabWidget, &QTabWidget::tabCloseRequested, this, &MainWindow::closeTab);
}
void MainWindow::closeTab(int i)
{
ui->tabWidget->removeTab(i);
}