Stack widget setCurrentWidget does not change the widget
-
Hi all,
This is my full code in one of the function.
m_centralStackedWidget->setCurrentWidget(m_windowSplitter); m_showSidebarAction->setEnabled(true);
There are two widgets being added to the central stacked widget.
- Welcomescreen (A QWidget) 2. QSplitter
When this function is triggered, the current widget of the m_centralStackedWidget
did change to the m_windowSplitter. However, the welcome screen does not hide, and the m_windowSplitter does not show up.
This is not an expected behavior. May I know if there is any rule for using this function? -
Hi,
This is not enough code to fully understand your issue.
Please provide a minimal compilable example that reproduces it.
-
Hello,
before using ->setCurrentWidget(), you can check if that widget is already contained in that stack widget or not.
you can m_centralStackedWidget->indexOf(m_windowSplitter) to find out if the widget is present in the stackwidget or not, it will return "-1" if the widget is not present in stackwidget