Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. TabBar with SwipeView
Qt 6.11 is out! See what's new in the release blog

TabBar with SwipeView

Scheduled Pinned Locked Moved Solved QML and Qt Quick
11 Posts 5 Posters 10.4k Views 2 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.
  • D Offline
    D Offline
    dauuser
    wrote on last edited by
    #2

    create qml components for each page and then put them inside the SwipeView:

    SwipeView{
       // properties...
      
      MyFirstPage{
        id: myFirstPage
      }
    
      MySecondPage{
         id: mySecondPage
      }
    
    }
    

    the SwipeView automatically sets MyFirstPage to index 0, MySecondPage to index 1 and so on.

    Naveen_DN 1 Reply Last reply
    2
    • D dauuser

      create qml components for each page and then put them inside the SwipeView:

      SwipeView{
         // properties...
        
        MyFirstPage{
          id: myFirstPage
        }
      
        MySecondPage{
           id: mySecondPage
        }
      
      }
      

      the SwipeView automatically sets MyFirstPage to index 0, MySecondPage to index 1 and so on.

      Naveen_DN Offline
      Naveen_DN Offline
      Naveen_D
      wrote on last edited by
      #3

      @dauuser You mean to say separate component like MyfirstPage.qml ( the content of this page in this .qml file) and then set this file in a swipe view ??

      Naveen_D

      D 1 Reply Last reply
      0
      • E Offline
        E Offline
        Eeli K
        wrote on last edited by
        #4

        TabBar is basically implemented with a list view or a path view where you add button-like delegates (usually TabButton) and behaves like a radiobutton group. The actual content is elsewhere and you can use TabBar even for other purposes without content pages if you really want to.

        1 Reply Last reply
        0
        • Naveen_DN Naveen_D

          Hi all

          I am using Tab bar with swipe view to develop a screen, i want to have different content for each page or each tab on the screen, but when i am trying to do that i get same content on each tab.

          Can anyone guide me, how to have different content on each tab ? and where i need to place the code for that either in Tab bar or in swipe view ?

          Thanks

          the code i am trying is as follows

          import QtQuick 2.0
          import QtQuick.Window 2.2
          import QtQuick.Controls 2.1
          
          ApplicationWindow {
              visible: true
              width: 750
              height: 400
          
              footer: TabBar {
                  id: tabBar
                  width: parent.width
                  currentIndex: swipeView.currentIndex
          
                  TabButton {
                      text: qsTr("Contacts")
                  }
                  TabButton {
                      text: qsTr("Call History")
                  }
                  TabButton {
                      text: qsTr("Dail Pad")
                  }
              }
          
          
              SwipeView{
                  id: swipeView
                  anchors.fill: parent
                  currentIndex: tabBar.currentIndex
          
                  Repeater {
                      model: 3
          
          //            Pane {
          //                width: swipeView.width
          //                height: swipeView.height
          //                Column {
          //                    spacing: 40
          //                    width: parent.width
          
          //                    Label {
          //                        width: parent.width
          //                        wrapMode: Label.Wrap
          //                        horizontalAlignment: Qt.AlignHCenter
          //                        text: "TabBar is a bar with icons or text which allows the user"
          //                              + "to switch between different subtasks, views, or modes."
          //                    }
          //                }
                          Item {
                              id: name
                              Rectangle {
                                  id: rect
                                  implicitHeight: 20
                                  implicitWidth: 50
                                  color:"red"
          //                        anchors.centerIn: swipeView
                              }
                          }
                      }
          //        }
              }
          
          }
          
          
          ekkescornerE Offline
          ekkescornerE Offline
          ekkescorner
          Qt Champions 2016
          wrote on last edited by
          #5

          @Naveen_D last year I have written a sample app for TabBar
          blogpost: https://appbus.wordpress.com/2016/06/07/tab-pages-app-tabbar/
          github: https://github.com/ekke/tab_pages_x
          hopefully you'll get some ideas

          ekke ... Qt Champion 2016 | 2024 ... mobile business apps

          Naveen_DN 1 Reply Last reply
          0
          • LorenzL Offline
            LorenzL Offline
            Lorenz
            wrote on last edited by
            #6

            Have a look at this code sample.

            The example shows how to put a red and a green rectangle inside a swipe view. You can replace these Rectangles with whatever QML item you like, as dauuser already indicated.

            If you need native style for iOS and Android, check out V-Play.

            Developer @ V-Play Engine - http://v-play.net/qt

            V-Play simplifies

            • Game Development with Qt
            • Mobile App Dev with Qt esp. iOS & Android

            What others say
            V-Play scored #1 in Cross-Platform App Development Tools Report - see why: https://goo.gl/rgp3rq

            Naveen_DN 1 Reply Last reply
            0
            • Naveen_DN Naveen_D

              @dauuser You mean to say separate component like MyfirstPage.qml ( the content of this page in this .qml file) and then set this file in a swipe view ??

              D Offline
              D Offline
              dauuser
              wrote on last edited by
              #7

              @Naveen_D yes, exactly

              1 Reply Last reply
              0
              • ekkescornerE ekkescorner

                @Naveen_D last year I have written a sample app for TabBar
                blogpost: https://appbus.wordpress.com/2016/06/07/tab-pages-app-tabbar/
                github: https://github.com/ekke/tab_pages_x
                hopefully you'll get some ideas

                Naveen_DN Offline
                Naveen_DN Offline
                Naveen_D
                wrote on last edited by
                #8

                @ekkescorner Yes sir, i referred your blog...its very helpful. Thanks

                Naveen_D

                1 Reply Last reply
                0
                • LorenzL Lorenz

                  Have a look at this code sample.

                  The example shows how to put a red and a green rectangle inside a swipe view. You can replace these Rectangles with whatever QML item you like, as dauuser already indicated.

                  If you need native style for iOS and Android, check out V-Play.

                  Naveen_DN Offline
                  Naveen_DN Offline
                  Naveen_D
                  wrote on last edited by
                  #9

                  @Lorenz Thanks for the information... to use this i need to install V-Play ?

                  Naveen_D

                  1 Reply Last reply
                  0
                  • LorenzL Offline
                    LorenzL Offline
                    Lorenz
                    wrote on last edited by
                    #10

                    Hi @Naveen_D
                    Yes, you need to install V-Play if you want the native styles etc. provided by V-Play.
                    However, the code sample I referred to should be usable also without V-Play:

                       // tab contents
                       QuickControls2.SwipeView {
                         id: swipeView
                         anchors.top: appTabBar.bottom
                         anchors.bottom: parent.bottom
                         width: parent.width
                         clip: true
                    
                         Rectangle {
                           color: "Red"
                         }
                    
                         Rectangle {
                           color: "Green"
                         }
                    
                       }
                    

                    Developer @ V-Play Engine - http://v-play.net/qt

                    V-Play simplifies

                    • Game Development with Qt
                    • Mobile App Dev with Qt esp. iOS & Android

                    What others say
                    V-Play scored #1 in Cross-Platform App Development Tools Report - see why: https://goo.gl/rgp3rq

                    Naveen_DN 1 Reply Last reply
                    0
                    • LorenzL Lorenz

                      Hi @Naveen_D
                      Yes, you need to install V-Play if you want the native styles etc. provided by V-Play.
                      However, the code sample I referred to should be usable also without V-Play:

                         // tab contents
                         QuickControls2.SwipeView {
                           id: swipeView
                           anchors.top: appTabBar.bottom
                           anchors.bottom: parent.bottom
                           width: parent.width
                           clip: true
                      
                           Rectangle {
                             color: "Red"
                           }
                      
                           Rectangle {
                             color: "Green"
                           }
                      
                         }
                      
                      Naveen_DN Offline
                      Naveen_DN Offline
                      Naveen_D
                      wrote on last edited by
                      #11

                      @Lorenz Thanks.

                      Naveen_D

                      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