-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathmainwindow.cpp
More file actions
36 lines (30 loc) · 927 Bytes
/
Copy pathmainwindow.cpp
File metadata and controls
36 lines (30 loc) · 927 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
#include <QToolButton>
#include <QTableWidget>
#include <QLabel>
#include "mainwindow.h"
#include "ui_mainwindow.h"
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
QToolButton *tb = new QToolButton();
tb->setText("+");
tb->setAutoRaise(true);
connect(tb, SIGNAL(clicked()), this, SLOT(addTab()));
ui->tabWidget->addTab(new QLabel("You can add tabs by pressing <b>\"+\"</b>"), QString());
ui->tabWidget->setTabEnabled(0, false);
ui->tabWidget->tabBar()->setTabButton(0, QTabBar::RightSide, tb);
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::addTab()
{
static int number = 0;
QLabel *tab = new QLabel(this);
QString tabName = QString("New tab #%1").arg(++number);
tab->setText( QString("Inside %1").arg(tabName) );
ui->tabWidget->insertTab( ui->tabWidget->count() - 1, tab, tabName);
}