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. Can't setCurrentIndex of SwipeView in onPressed slot
Qt 6.11 is out! See what's new in the release blog

Can't setCurrentIndex of SwipeView in onPressed slot

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
2 Posts 2 Posters 285 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.
  • G Offline
    G Offline
    GWJ0324
    wrote on last edited by
    #1

    I try to set currentIndex of SwipeView in the slot of onPressed,but the red page does not switch to the blue page.When I try to set currentIndex of SwipeView in the slot of onClicked,that's all right.I use the Qt6.5.3.Is it a bug of Qt?

    import QtQuick 6.2
    import QtQuick.Controls.Basic 6.5
    Window {
        width: 600
        height: 500
        visible: true
    
        SwipeView {
            id: swipeView
            currentIndex: tabBar.currentIndex
            anchors.top: tabBar.bottom
            anchors.left: parent.left
            anchors.right:parent.right
            anchors.bottom: parent.bottom
            Rectangle{
                color: "red"
                Button {
                    //onClicked: swipeView.setCurrentIndex(1);
                    onPressed: swipeView.setCurrentIndex(1);
                }
            }
            Rectangle{
                color: "blue"
            }
        }
        TabBar {
            id: tabBar
            anchors.top: parent.top
            anchors.left: parent.left
            anchors.right: parent.right
            currentIndex: swipeView.currentIndex
            TabButton{}
            TabButton{}
        }
    }
    
    1 Reply Last reply
    0
    • Marko StankeM Offline
      Marko StankeM Offline
      Marko Stanke
      wrote on last edited by
      #2
      swipeView.currentIndex = 1
      

      Should do the trick

      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