Stack view problem



  • Hi

    In my project, the 5 tab bar contain five different pages. Each page is created on the item container. I load the each page in the rectangle as stack view child item. If I run the program , the all the page will appear in the rectangle at first time. The initial page didn't appear first.

    sample code:
    StackView{
    id:stack
    anchors.fill: rect_stackview
    initialItem: page_first

            First{
                id:page_first
               //visible: false
            }
            Second{
                id:page_second
             //   visible: false
            }
           Third{
                id:page_third
               // visible: false
    
            }
            Fourth{
                id:page_fourth
           //     visible: false
            }
    

    If i put visible =false, the stackview is working fine, otherwise all the page appear in the rectangle. How can i solve this problem without set visible as false ?



  • @eswar I suppose your sample code isn't copypasted, you have "initialItem: page_First" but " id:page_first" which doesn't work.



  • @Eeli-K

    Hi

    oh sorry.. It just typo.. i edit some code...

    This is my problem
    If i put visible =false, the stackview is working fine, otherwise all the page appear in the rectangle. How can i solve this problem without setting visible as false ?



  • @eswar Can you create a minimal project which shows the problem? Just main.qml and two pages which can be run as-is with Qt Creator?



  • You can do like this :

    Rectangle {
        id: baseComponent
    
        property Item first: Item { id: first_item }
        property Item second: Item { ... }
        property Item third: Item { ... }
        property Item fourth: Item { ... }
    
        StackView {
            anchors.fill: parent
            initialItem: first_item
        }
    }
    

    Hope it helped!



  • @ibia

    Hi

    Thanks for your reply . My issue solved.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.