@@ -1,21 +1,24 | |||||
1 | #ifndef SCIQLOP_VISUALIZATIONWIDGET_H |
|
1 | #ifndef SCIQLOP_VISUALIZATIONWIDGET_H | |
2 | #define SCIQLOP_VISUALIZATIONWIDGET_H |
|
2 | #define SCIQLOP_VISUALIZATIONWIDGET_H | |
3 |
|
3 | |||
|
4 | #include <QLoggingCategory> | |||
4 | #include <QWidget> |
|
5 | #include <QWidget> | |
5 |
|
6 | |||
|
7 | Q_DECLARE_LOGGING_CATEGORY(LOG_VisualizationWidget) | |||
|
8 | ||||
6 | namespace Ui { |
|
9 | namespace Ui { | |
7 | class VisualizationWidget; |
|
10 | class VisualizationWidget; | |
8 | } // namespace Ui |
|
11 | } // namespace Ui | |
9 |
|
12 | |||
10 | class VisualizationWidget : public QWidget { |
|
13 | class VisualizationWidget : public QWidget { | |
11 | Q_OBJECT |
|
14 | Q_OBJECT | |
12 |
|
15 | |||
13 | public: |
|
16 | public: | |
14 | explicit VisualizationWidget(QWidget *parent = 0); |
|
17 | explicit VisualizationWidget(QWidget *parent = 0); | |
15 | virtual ~VisualizationWidget(); |
|
18 | virtual ~VisualizationWidget(); | |
16 |
|
19 | |||
17 | private: |
|
20 | private: | |
18 | Ui::VisualizationWidget *ui; |
|
21 | Ui::VisualizationWidget *ui; | |
19 | }; |
|
22 | }; | |
20 |
|
23 | |||
21 | #endif // VISUALIZATIONWIDGET_H |
|
24 | #endif // VISUALIZATIONWIDGET_H |
@@ -1,13 +1,43 | |||||
1 | #include "visualization/VisualizationWidget.h" |
|
1 | #include "visualization/VisualizationWidget.h" | |
2 | #include "ui_VisualizationWidget.h" |
|
2 | #include "ui_VisualizationWidget.h" | |
|
3 | #include "visualization/VisualizationTabWidget.h" | |||
|
4 | ||||
|
5 | #include <QDebug> | |||
|
6 | #include <QToolButton> | |||
|
7 | ||||
|
8 | #include "iostream" | |||
|
9 | ||||
|
10 | Q_LOGGING_CATEGORY(LOG_VisualizationWidget, "VisualizationWidget") | |||
3 |
|
11 | |||
4 | VisualizationWidget::VisualizationWidget(QWidget *parent) |
|
12 | VisualizationWidget::VisualizationWidget(QWidget *parent) | |
5 | : QWidget(parent), ui(new Ui::VisualizationWidget) |
|
13 | : QWidget(parent), ui(new Ui::VisualizationWidget) | |
6 | { |
|
14 | { | |
7 | ui->setupUi(this); |
|
15 | ui->setupUi(this); | |
|
16 | ||||
|
17 | auto *addTabViewButton = new QToolButton(ui->tabWidget); | |||
|
18 | addTabViewButton->setText("Add View"); | |||
|
19 | addTabViewButton->setCursor(Qt::ArrowCursor); | |||
|
20 | addTabViewButton->setAutoRaise(true); | |||
|
21 | ui->tabWidget->setCornerWidget(addTabViewButton, Qt::TopRightCorner); | |||
|
22 | ||||
|
23 | auto addTabView = [&](bool checked) { | |||
|
24 | auto index = ui->tabWidget->addTab(new VisualizationTabWidget(ui->tabWidget), | |||
|
25 | QString("View %1").arg(ui->tabWidget->count() + 1)); | |||
|
26 | qCInfo(LOG_VisualizationWidget()) << tr("add the tab of index %1").arg(index); | |||
|
27 | }; | |||
|
28 | ||||
|
29 | auto removeTabView = [&](int index) { | |||
|
30 | ui->tabWidget->removeTab(index); | |||
|
31 | qCInfo(LOG_VisualizationWidget()) << tr("remove the tab of index %1").arg(index); | |||
|
32 | }; | |||
|
33 | ||||
|
34 | ui->tabWidget->setTabsClosable(true); | |||
|
35 | ||||
|
36 | connect(addTabViewButton, &QToolButton::clicked, addTabView); | |||
|
37 | connect(ui->tabWidget, &QTabWidget::tabCloseRequested, removeTabView); | |||
8 | } |
|
38 | } | |
9 |
|
39 | |||
10 | VisualizationWidget::~VisualizationWidget() |
|
40 | VisualizationWidget::~VisualizationWidget() | |
11 | { |
|
41 | { | |
12 | delete ui; |
|
42 | delete ui; | |
13 | } |
|
43 | } |
@@ -1,38 +1,41 | |||||
1 | <?xml version="1.0" encoding="UTF-8"?> |
|
1 | <?xml version="1.0" encoding="UTF-8"?> | |
2 | <ui version="4.0"> |
|
2 | <ui version="4.0"> | |
3 | <class>VisualizationWidget</class> |
|
3 | <class>VisualizationWidget</class> | |
4 | <widget class="QWidget" name="VisualizationWidget"> |
|
4 | <widget class="QWidget" name="VisualizationWidget"> | |
5 | <property name="geometry"> |
|
5 | <property name="geometry"> | |
6 | <rect> |
|
6 | <rect> | |
7 | <x>0</x> |
|
7 | <x>0</x> | |
8 | <y>0</y> |
|
8 | <y>0</y> | |
9 | <width>400</width> |
|
9 | <width>400</width> | |
10 | <height>300</height> |
|
10 | <height>300</height> | |
11 | </rect> |
|
11 | </rect> | |
12 | </property> |
|
12 | </property> | |
13 | <property name="windowTitle"> |
|
13 | <property name="windowTitle"> | |
14 | <string>Form</string> |
|
14 | <string>Form</string> | |
15 | </property> |
|
15 | </property> | |
16 | <layout class="QVBoxLayout" name="verticalLayout"> |
|
16 | <layout class="QVBoxLayout" name="verticalLayout"> | |
17 | <item> |
|
17 | <item> | |
18 | <widget class="QTabWidget" name="tabWidget"> |
|
18 | <widget class="QTabWidget" name="tabWidget"> | |
19 | <property name="currentIndex"> |
|
19 | <property name="currentIndex"> | |
20 | <number>0</number> |
|
20 | <number>0</number> | |
21 | </property> |
|
21 | </property> | |
22 |
<widget class=" |
|
22 | <widget class="VisualizationTabWidget" name="firstView"> | |
23 | <attribute name="title"> |
|
23 | <attribute name="title"> | |
24 | <string>View 1</string> |
|
24 | <string>View 1</string> | |
25 | </attribute> |
|
25 | </attribute> | |
26 | </widget> |
|
26 | </widget> | |
27 | <widget class="QWidget" name="secondView"> |
|
|||
28 | <attribute name="title"> |
|
|||
29 | <string>+</string> |
|
|||
30 | </attribute> |
|
|||
31 | </widget> |
|
|||
32 | </widget> |
|
27 | </widget> | |
33 | </item> |
|
28 | </item> | |
34 | </layout> |
|
29 | </layout> | |
35 | </widget> |
|
30 | </widget> | |
|
31 | <customwidgets> | |||
|
32 | <customwidget> | |||
|
33 | <class>VisualizationTabWidget</class> | |||
|
34 | <extends>QWidget</extends> | |||
|
35 | <header location="global">visualization/VisualizationTabWidget.h</header> | |||
|
36 | <container>1</container> | |||
|
37 | </customwidget> | |||
|
38 | </customwidgets> | |||
36 | <resources/> |
|
39 | <resources/> | |
37 | <connections/> |
|
40 | <connections/> | |
38 | </ui> |
|
41 | </ui> |
General Comments 0
You need to be logged in to leave comments.
Login now