-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwidgetcontainer.cpp
More file actions
35 lines (32 loc) · 845 Bytes
/
widgetcontainer.cpp
File metadata and controls
35 lines (32 loc) · 845 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
#include "widgetcontainer.h"
#include <QDebug>
WidgetContainer::WidgetContainer(QWidget *parent) : QWidget(parent)
{
currentWidget = nullptr;
vLayout = new QVBoxLayout();
vLayout->setMargin(0);
vLayout->setSpacing(0);
this->setLayout(vLayout);
}
void WidgetContainer::SetWidget(QWidget *widget)
{
// there should be only one widget
qDebug() << "set widget" << widget;
if(currentWidget != nullptr){
vLayout->removeWidget(currentWidget);
currentWidget->hide();
}
vLayout->addWidget(widget);
currentWidget = widget;
widget->show();
}
QWidget* WidgetContainer::DeleteWidget()
{
if(currentWidget != nullptr){
vLayout->removeWidget(currentWidget);
QWidget* temp = currentWidget;
currentWidget = nullptr;
return temp;
}
return nullptr;
}