##// END OF EJS Templates
Initializes the variable inspector and adds it to the MainWindow
Initializes the variable inspector and adds it to the MainWindow

File last commit:

r98:9678ebc27091
r105:1002063c9aa2
Show More
VisualizationWidget.cpp
43 lines | 1.4 KiB | text/x-c | CppLexer
/ gui / src / Visualization / VisualizationWidget.cpp
#include "Visualization/VisualizationWidget.h"
#include "Visualization/VisualizationTabWidget.h"
#include "ui_VisualizationWidget.h"
#include <QDebug>
#include <QToolButton>
#include "iostream"
Q_LOGGING_CATEGORY(LOG_VisualizationWidget, "VisualizationWidget")
VisualizationWidget::VisualizationWidget(QWidget *parent)
: QWidget{parent}, ui{new Ui::VisualizationWidget}
{
ui->setupUi(this);
auto addTabViewButton = new QToolButton{ui->tabWidget};
addTabViewButton->setText(tr("Add View"));
addTabViewButton->setCursor(Qt::ArrowCursor);
addTabViewButton->setAutoRaise(true);
ui->tabWidget->setCornerWidget(addTabViewButton, Qt::TopRightCorner);
auto addTabView = [&]() {
auto index = ui->tabWidget->addTab(new VisualizationTabWidget(ui->tabWidget),
QString("View %1").arg(ui->tabWidget->count() + 1));
qCInfo(LOG_VisualizationWidget()) << tr("add the tab of index %1").arg(index);
};
auto removeTabView = [&](int index) {
ui->tabWidget->removeTab(index);
qCInfo(LOG_VisualizationWidget()) << tr("remove the tab of index %1").arg(index);
};
ui->tabWidget->setTabsClosable(true);
connect(addTabViewButton, &QToolButton::clicked, addTabView);
connect(ui->tabWidget, &QTabWidget::tabCloseRequested, removeTabView);
}
VisualizationWidget::~VisualizationWidget()
{
delete ui;
}