mirror of
https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System.git
synced 2024-12-25 07:31:33 +08:00
Changed sizeHints(), sizePolicy() and used updateGeometry() to properly size the tabBar
This commit is contained in:
parent
9d7c692398
commit
ae72f5e47d
@ -123,23 +123,24 @@ CDockAreaTabBar::CDockAreaTabBar(CDockAreaWidget* parent) :
|
|||||||
d(new DockAreaTabBarPrivate(this))
|
d(new DockAreaTabBarPrivate(this))
|
||||||
{
|
{
|
||||||
d->DockArea = parent;
|
d->DockArea = parent;
|
||||||
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
|
setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
|
||||||
setFrameStyle(QFrame::NoFrame);
|
setFrameStyle(QFrame::NoFrame);
|
||||||
setWidgetResizable(true);
|
setWidgetResizable(true);
|
||||||
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||||
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||||
|
|
||||||
d->TabsContainerWidget = new QWidget();
|
d->TabsContainerWidget = new QWidget();
|
||||||
|
d->TabsContainerWidget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
|
||||||
d->TabsContainerWidget->setObjectName("tabsContainerWidget");
|
d->TabsContainerWidget->setObjectName("tabsContainerWidget");
|
||||||
setWidget(d->TabsContainerWidget);
|
|
||||||
|
|
||||||
d->TabsLayout = new QBoxLayout(QBoxLayout::LeftToRight);
|
d->TabsLayout = new QBoxLayout(QBoxLayout::LeftToRight);
|
||||||
d->TabsLayout->setContentsMargins(0, 0, 0, 0);
|
d->TabsLayout->setContentsMargins(0, 0, 0, 0);
|
||||||
d->TabsLayout->setSpacing(0);
|
d->TabsLayout->setSpacing(0);
|
||||||
d->TabsLayout->addStretch(1);
|
d->TabsLayout->addStretch(1);
|
||||||
d->TabsContainerWidget->setLayout(d->TabsLayout);
|
d->TabsContainerWidget->setLayout(d->TabsLayout);
|
||||||
|
setWidget(d->TabsContainerWidget);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
CDockAreaTabBar::~CDockAreaTabBar()
|
CDockAreaTabBar::~CDockAreaTabBar()
|
||||||
{
|
{
|
||||||
@ -350,6 +351,8 @@ void CDockAreaTabBar::insertTab(int Index, CDockWidgetTab* Tab)
|
|||||||
{
|
{
|
||||||
setCurrentIndex(d->CurrentIndex + 1);
|
setCurrentIndex(d->CurrentIndex + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
updateGeometry();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -412,6 +415,8 @@ void CDockAreaTabBar::removeTab(CDockWidgetTab* Tab)
|
|||||||
{
|
{
|
||||||
d->updateTabs();
|
d->updateTabs();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
updateGeometry();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -620,7 +625,8 @@ bool CDockAreaTabBar::isTabOpen(int Index) const
|
|||||||
QSize CDockAreaTabBar::minimumSizeHint() const
|
QSize CDockAreaTabBar::minimumSizeHint() const
|
||||||
{
|
{
|
||||||
QSize Size = sizeHint();
|
QSize Size = sizeHint();
|
||||||
Size.setWidth(Super::minimumSizeHint().width());// this defines the minimum width of a dock area
|
//Size.setWidth(Super::minimumSizeHint().width());// this defines the minimum width of a dock area
|
||||||
|
Size.setWidth(10);
|
||||||
return Size;
|
return Size;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -628,9 +634,7 @@ QSize CDockAreaTabBar::minimumSizeHint() const
|
|||||||
//===========================================================================
|
//===========================================================================
|
||||||
QSize CDockAreaTabBar::sizeHint() const
|
QSize CDockAreaTabBar::sizeHint() const
|
||||||
{
|
{
|
||||||
QSize Size = Super::sizeHint();
|
return d->TabsContainerWidget->sizeHint();
|
||||||
Size.setHeight(d->TabsContainerWidget->sizeHint().height());
|
|
||||||
return Size;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -253,9 +253,12 @@ CDockAreaTitleBar::CDockAreaTitleBar(CDockAreaWidget* parent) :
|
|||||||
d->TopLayout->setContentsMargins(0, 0, 0, 0);
|
d->TopLayout->setContentsMargins(0, 0, 0, 0);
|
||||||
d->TopLayout->setSpacing(0);
|
d->TopLayout->setSpacing(0);
|
||||||
setLayout(d->TopLayout);
|
setLayout(d->TopLayout);
|
||||||
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
|
setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
|
||||||
|
|
||||||
d->createTabBar();
|
d->createTabBar();
|
||||||
|
d->TabBar->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Preferred);
|
||||||
|
auto horizontalSpacer = new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum);
|
||||||
|
d->TopLayout->addSpacerItem(horizontalSpacer);
|
||||||
d->createButtons();
|
d->createButtons();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -451,6 +451,7 @@ void CDockWidgetTab::setActiveTab(bool active)
|
|||||||
d->TitleLabel->style()->unpolish(d->TitleLabel);
|
d->TitleLabel->style()->unpolish(d->TitleLabel);
|
||||||
d->TitleLabel->style()->polish(d->TitleLabel);
|
d->TitleLabel->style()->polish(d->TitleLabel);
|
||||||
update();
|
update();
|
||||||
|
updateGeometry();
|
||||||
|
|
||||||
emit activeTabChanged();
|
emit activeTabChanged();
|
||||||
}
|
}
|
||||||
|
@ -92,3 +92,8 @@ QScrollArea#dockWidgetScrollArea
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
ads--CDockAreaTitleBar
|
||||||
|
{
|
||||||
|
background: red;
|
||||||
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user