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. Create Image carousel with SwipeView
Qt 6.11 is out! See what's new in the release blog

Create Image carousel with SwipeView

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

    hello, i need to create multiple image carousel with SwipeView but it's showing just one image at once. can someone help me how i can get something like this using SwipeView or other way please?
    44ad5787-66f2-4a83-ad81-301864f8c182-image.png

    property var img: ['Toyota', 'Audi', 'Citroen', 'Fiat', 'Ford', 'Honda']
    
    Rectangle {
        width: 560
        height: 215
        border.width: 1
        border.color: 'lightgrey'
        anchors.centerIn: parent
    
        SwipeView {
            id: caroussel
            clip: true
            anchors.fill: parent
            currentIndex: indicator.currentIndex
    
            Repeater {
                model: 6
    
                Rectangle {
                    border.width: 1
                    border.color: '#000'
                    Image {
                        source: 'brands/'+ img[index]
                        fillMode: Image.PreserveAspectFit
                        anchors.fill: parent
                    }
                }
            }
        }
    }
    
    PageIndicator {
        id: indicator
        count: caroussel.count
        anchors.bottom: parent.bottom
        x: (parent.width/2) - (width/2)
        currentIndex: caroussel.currentIndex
        transform: Translate {
            y: -50
        }
    }
    

    thanks

    D 1 Reply Last reply
    0
    • T Trj6

      hello, i need to create multiple image carousel with SwipeView but it's showing just one image at once. can someone help me how i can get something like this using SwipeView or other way please?
      44ad5787-66f2-4a83-ad81-301864f8c182-image.png

      property var img: ['Toyota', 'Audi', 'Citroen', 'Fiat', 'Ford', 'Honda']
      
      Rectangle {
          width: 560
          height: 215
          border.width: 1
          border.color: 'lightgrey'
          anchors.centerIn: parent
      
          SwipeView {
              id: caroussel
              clip: true
              anchors.fill: parent
              currentIndex: indicator.currentIndex
      
              Repeater {
                  model: 6
      
                  Rectangle {
                      border.width: 1
                      border.color: '#000'
                      Image {
                          source: 'brands/'+ img[index]
                          fillMode: Image.PreserveAspectFit
                          anchors.fill: parent
                      }
                  }
              }
          }
      }
      
      PageIndicator {
          id: indicator
          count: caroussel.count
          anchors.bottom: parent.bottom
          x: (parent.width/2) - (width/2)
          currentIndex: caroussel.currentIndex
          transform: Translate {
              y: -50
          }
      }
      

      thanks

      D Offline
      D Offline
      Drooke
      wrote on last edited by
      #2

      @Trj6 it may be because your rectangle in the delegate of the repeater has no dimensions. Try adding a width and height property to match your images.

      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