Unsolved How to iterate components dynamically using stackview?
-
I wanted to know how to iterate between components dynamically using stackView. Let's say, I have an application window with five buttons. I wanted to show a small window within the application if I click any of the buttons. For Eg: There are five buttons and five components. Each button is associated with a component. These components are in stackVIew. If I click button 1, page 1 should appear within the application. Similarly, if I click button 2, page 2 should appear instead of page 1. I know this can be achieved using stackview, but I am unable to find the right solution for it.
Can anyone help me, To achieve this?. Thanks in advance.
-
@lakshmanGiri hi
That is almost what the first example in the documentation does just use push and pop functions
see also find and get https://doc.qt.io/qt-5/qml-qtquick-controls2-stackview.html#finding-items -
why not consider using QStackedWidget?as far as I know,QStackedWidget can perform similar functions as you mentioned,for example:you can place a QStackedWidget component in the UI of the application,and then insert several pages into it,if you want to switch these pages,just use simple【QStackedWidget::setCurrentIndex(para)】to set the page you want
-
@Poor-English It's about QML here, not Qt Widgets.
-
@lakshmanGiri there's a (really outdated) example I made some years before about this while learning Qt and QML:
https://github.com/ekke/stacked_pages_x
https://appbus.wordpress.com/2016/05/27/stacked-pages-app/
don't know if it's running out of the box but perhaps gives you some ideasBTW: this year I'll update all my examples and write new blogs while transform to Qt 5.15-->Qt6.2
-
@jsulm
Oh,I'm sorry!my English is not good,and I can't understand the partitions inside。In fact,I have to work hard to find the posts I have posted before,including pictures,so far I haven't figured out how to upload them。。。 -
@Poor-English said in How to iterate components dynamically using stackview?:
I have to work hard to find the posts I have posted before
Simply go to your profile: on the upper right side click on your avatar icon and go to your profile.
Image upload often does not work properly here. You can upload images to some sharing service and post the link then.