UI: HomeWindow: Fix window flickering on open

This commit is contained in:
Nodir Temirkhodjaev 2024-04-18 11:19:04 +03:00
parent b2bf6ff301
commit edb0bc5e3f
2 changed files with 9 additions and 9 deletions

View File

@ -2,7 +2,7 @@
#include <QIcon> #include <QIcon>
#include <QLabel> #include <QLabel>
#include <QStackedLayout> #include <QStackedWidget>
#include <QToolButton> #include <QToolButton>
#include <QVBoxLayout> #include <QVBoxLayout>
@ -39,7 +39,7 @@ void HomeMainPage::setupUi()
setupStackedLayout(); setupStackedLayout();
layout->addLayout(sideBar); layout->addLayout(sideBar);
layout->addLayout(m_stackedLayout, 1); layout->addWidget(m_stackedPages, 1);
this->setLayout(layout); this->setLayout(layout);
} }
@ -74,18 +74,18 @@ void HomeMainPage::setupSideBarButtons()
void HomeMainPage::setupStackedLayout() void HomeMainPage::setupStackedLayout()
{ {
m_stackedLayout = new QStackedLayout(); m_stackedPages = new QStackedWidget();
m_stackedLayout->addWidget(new HomePage(ctrl())); m_stackedPages->addWidget(new HomePage(ctrl()));
m_stackedLayout->addWidget(new AboutPage(ctrl())); m_stackedPages->addWidget(new AboutPage(ctrl()));
} }
void HomeMainPage::setCurrentTab(TabIndex tabIndex) void HomeMainPage::setCurrentTab(TabIndex tabIndex)
{ {
if (m_stackedLayout->currentIndex() == tabIndex) if (m_stackedPages->currentIndex() == tabIndex)
return; return;
m_stackedLayout->setCurrentIndex(tabIndex); m_stackedPages->setCurrentIndex(tabIndex);
buttonAt(tabIndex)->animateClick(); buttonAt(tabIndex)->animateClick();
} }

View File

@ -3,7 +3,7 @@
#include "homebasepage.h" #include "homebasepage.h"
QT_FORWARD_DECLARE_CLASS(QStackedLayout) QT_FORWARD_DECLARE_CLASS(QStackedWidget)
class HomeMainPage : public HomeBasePage class HomeMainPage : public HomeBasePage
{ {
@ -30,7 +30,7 @@ private:
private: private:
QVector<QToolButton *> m_buttons; QVector<QToolButton *> m_buttons;
QStackedLayout *m_stackedLayout = nullptr; QStackedWidget *m_stackedPages = nullptr;
}; };
#endif // HOMEMAINPAGE_H #endif // HOMEMAINPAGE_H