-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathmainwindow.cpp
More file actions
40 lines (32 loc) · 825 Bytes
/
Copy pathmainwindow.cpp
File metadata and controls
40 lines (32 loc) · 825 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
40
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include "dialog.h"
#include <QPushButton>
#include <QtDebug>
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
ui->tabWidget->addTab(new Dialog, "dialog" );
auto * btn = new QPushButton("corner");
connect(btn, &QPushButton::clicked, [](){
qDebug() << "clicked";
});
ui->tabWidget->setCornerWidget(btn);
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::on_tabWidget_currentChanged(int index)
{
auto *w = dynamic_cast<AbstractEdit*>(ui->tabWidget->widget(index));
if (w){
w->setText(QString::fromStdString(std::to_string(index)));
}
}
void MainWindow::on_tabWidget_tabCloseRequested(int index)
{
ui->tabWidget->removeTab(index);
}