Insert a SwipeView with dynamic number of pages into a TabBar with 2 Tabs

  • Hello everybody

    I have a page with a swipeView which has a variable number of pages.

    This page loads an hourly schedule of a thermostat from a Rest API and this part after a few days I managed to make it work. It also works swipe, in the sense that by turning the pages it loads the corresponding programming.

    Now another part is missing, which is to change the season.

    The 2 tabs represent the season, therefore summer and winter. When I open the page it must show the Summer season, and when I click on Winter it must load the Winter season.

    In practice, in the Rest API I spend the current season, so at the call of the API I already foresee this parameter, and what I am missing is just inserting this already working swipe into a tabbar, and pass the season as a parameter directly from the tab.

    I also want to avoid conflicts between the swipeview and the tabbar, because in the swipe I use the swipe index to pass it to the API to load the correct page programming. But in addition to the swipe index, I also have to pass the tab index separately.

    I hope I was clear. If there are doubts, let me know that I try to clarify them better.


  • Have you seen the vanilla project template for a "Qt Quick Application - Swipe"? Cause that has a simple swipe/tab index relationship working. It has 2 tabs to control the swipe index. While hardcoded in the template, the swipe model needn't be.

    I use a SwipeView connected to a TabView, with the SwipeView model a ListModel, the delegate a Repeater.

    All the rest of your details frankly are yours to deal with / irrelevant to these 2 controls. I'd recommend: change the data / behaviour by using and changing models and for changing selections by changing the Swipe&Tab indexes. The details of what does what when is your job.

  • I resolve problem but now I have conflict between currentIndex of TabBar and SwipeView.

    If I change TabBar change also index of Swipe, and I don't want this.

    How can resolve this issue?

    Thank you.

  • In fact, I just realized that it is not a question of conflict, but of synchronization.

    Basically I said 2 tabs: Summer and Winter, and each of these 2 tabs assumes that 3 pages.

    I am in the summer season and on page 1, and if I go to winter I am always on page 1.

    But if from the summer page I go to page 3, in a certain way the index moved only in the summer season, and in the winter one I stayed on page 1.

    How can I synchronize the swipeView index between the 2 tabs? In practice, if from summer I go to page 3, and then I go to the winter tab, winter must also go to page 3 as soon as I click on the winter tab. So in addition to switching and loading the winter programming, it must take me to the same page I had before going to winter.

    Thank you

Log in to reply