Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. General talk
  3. Qt 6
  4. Stack widget setCurrentWidget does not change the widget
Qt 6.11 is out! See what's new in the release blog

Stack widget setCurrentWidget does not change the widget

Scheduled Pinned Locked Moved Unsolved Qt 6
3 Posts 3 Posters 639 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • W Offline
    W Offline
    www111
    wrote on last edited by
    #1

    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.

    1. 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?

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      This is not enough code to fully understand your issue.

      Please provide a minimal compilable example that reproduces it.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      2
      • J Offline
        J Offline
        Jyothi
        wrote on last edited by
        #3

        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

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved