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. QML SwipeView Signals
QtWS25 Last Chance

QML SwipeView Signals

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
5 Posts 3 Posters 4.2k Views
  • 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.
  • Z Offline
    Z Offline
    zeroc8
    wrote on last edited by zeroc8
    #1

    Hi, is there any signal I can connect to when a SwipeView Page gets loaded?

    SwipeView {
             // this doesn't work
             // onChanged: { console.log('page changed'); }
       Page {
              // this doesn't work
             // onLoaded: { console.log('page loaded'); }
      }
    Page {
      }
    Page {
      }
    }
    
    ? 1 Reply Last reply
    0
    • Z zeroc8

      Hi, is there any signal I can connect to when a SwipeView Page gets loaded?

      SwipeView {
               // this doesn't work
               // onChanged: { console.log('page changed'); }
         Page {
                // this doesn't work
               // onLoaded: { console.log('page loaded'); }
        }
      Page {
        }
      Page {
        }
      }
      
      ? Offline
      ? Offline
      A Former User
      wrote on last edited by
      #2

      Hi! You can use onCurrentIndexChanged:

      SwipeView {
              id: view
              anchors.fill: parent
              
              currentIndex: 1
              onCurrentIndexChanged: console.log(currentIndex)
              
              Rectangle {
                  color: "red"
                  width: 300
                  height: 400
              }
              Rectangle {
                  color: "green"
                  width: 300
                  height: 400
              }
              Rectangle {
                  color: "blue"
                  width: 300
                  height: 400
              }
          }
      
      Z 1 Reply Last reply
      1
      • jpnurmiJ Offline
        jpnurmiJ Offline
        jpnurmi
        wrote on last edited by
        #3

        Perhaps the SwipeView.isCurrentItem attached property is of use for you?

        SwipeView {
            Rectangle {
                color: SwipeView.isCurrentItem ? "red" : "green"
            }
        }
        
        1 Reply Last reply
        1
        • ? A Former User

          Hi! You can use onCurrentIndexChanged:

          SwipeView {
                  id: view
                  anchors.fill: parent
                  
                  currentIndex: 1
                  onCurrentIndexChanged: console.log(currentIndex)
                  
                  Rectangle {
                      color: "red"
                      width: 300
                      height: 400
                  }
                  Rectangle {
                      color: "green"
                      width: 300
                      height: 400
                  }
                  Rectangle {
                      color: "blue"
                      width: 300
                      height: 400
                  }
              }
          
          Z Offline
          Z Offline
          zeroc8
          wrote on last edited by
          #4

          @Wieland Thankyou, that works. It seems that signal is missing from the documentation that comes with QtCreator.

          jpnurmiJ 1 Reply Last reply
          0
          • Z zeroc8

            @Wieland Thankyou, that works. It seems that signal is missing from the documentation that comes with QtCreator.

            jpnurmiJ Offline
            jpnurmiJ Offline
            jpnurmi
            wrote on last edited by
            #5

            Property Change Signal Handlers:
            http://doc.qt.io/qt-5/qtqml-syntax-signals.html#property-change-signal-handlers

            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