Qt 6.11 is out! See what's new in the release
blog
Can't setCurrentIndex of SwipeView in onPressed slot
-
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{} } } -
swipeView.currentIndex = 1Should do the trick