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. Scroll view
Forum Updated to NodeBB v4.3 + New Features

Scroll view

Scheduled Pinned Locked Moved QML and Qt Quick
28 Posts 3 Posters 7.6k 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.
  • shavS Offline
    shavS Offline
    shav
    wrote on last edited by
    #2

    Hi,

    You can use ListView to show list of images which user will select or use GridView to show image as a grid. Code with ListView should looks like:
    @
    property var imagesListModel: ["image1.png","image2.png","image3.png", ...]

    ListView {
    id: imagesList
    anchors.fill: parent
    model: imagesListModel
    delegate: Image {
    width: imagesList.width
    height: 100
    source: imagesListModel[index]

         MouseArea {
             anchors.fill: parent
    
             onClicked: {
                  console.log("User select '"+imagesListModel[index]+"' image");
             }
         }
    }
    

    }
    @

    Code with GridView will looks like above.

    Mac OS and iOS Developer

    1 Reply Last reply
    0
    • J Offline
      J Offline
      Javeria
      wrote on last edited by
      #3

      !https://www.google.com.pk/search?q=image+grid+view&es_sm=93&biw=1366&bih=643&source=lnms&tbm=isch&sa=X&ei=7U_gVO7iNJPXaurKgcAI&ved=0CAYQ_AUoAQ#tbm=isch&q=image+scroller&imgdii=_&imgrc=uR83Buz403WwlM%3A;QKtst0YoywqgPM;http%3A%2F%2Fblog.atomictemplates.com%2Fwp-content%2Fuploads%2F2010%2F05%2FCreate-a-Thumbs-Scroller-with-AS3-and-XML.jpg;http%3A%2F%2Fblog.atomictemplates.com%2Fflash-tutorials%2Fcreate-flash-image-scrollers-flash-image-galleries-easily%2F;465;139()!

      I want the list to look close to this, is it possible in QML?

      1 Reply Last reply
      0
      • p3c0P Offline
        p3c0P Offline
        p3c0
        Moderators
        wrote on last edited by
        #4

        Hi,

        It seems you want te List to be horizontal. You can do that by changing the "orientation":http://doc.qt.io/qt-5/qml-qtquick-listview.html#listview-layouts to horizontal.

        Also please use Link tag to post the links.

        157

        1 Reply Last reply
        0
        • J Offline
          J Offline
          Javeria
          wrote on last edited by
          #5

          Okay but how will show the list values as images?

          1 Reply Last reply
          0
          • p3c0P Offline
            p3c0P Offline
            p3c0
            Moderators
            wrote on last edited by
            #6

            In the similar way shav have explained earlier. Basically its the delegate which is used as a view.

            157

            1 Reply Last reply
            0
            • J Offline
              J Offline
              Javeria
              wrote on last edited by
              #7

              I have tried this but the view is not visible, i have also set the visibility to true

              1 Reply Last reply
              0
              • p3c0P Offline
                p3c0P Offline
                p3c0
                Moderators
                wrote on last edited by
                #8

                Ok. It would be better if you post the code or probably a complete minimal sample.

                157

                1 Reply Last reply
                0
                • J Offline
                  J Offline
                  Javeria
                  wrote on last edited by
                  #9

                  @ApplicationWindow {
                  id : hola
                  title: ("SketchIt")
                  width: 640
                  height: 480
                  minimumWidth: mainToolBar .implicitWidth
                  visible: true

                  Image{
                      visible:true
                   source:"C:\\1.jpg"
                   sourceSize.width:hola.width/2
                   sourceSize.height:hola.height/2
                  }
                  toolBar: ToolBar{
                      id : mainToolBar
                      anchors.fill :parent
                      RowLayout{
                       //   width : parent.width
                  
                          ToolButton{
                         // text : ("main")
                          iconSource: "C:\\Users\\Hassan Adil\\Documents\\sketchIt\\16.png"
                          onClicked: hola.color = "blue"
                          anchors.margins: 4
                  

                  }

                      Button{
                  
                          text : "close"
                          onClicked: hola.close()
                  

                  }
                  }
                  }
                  SplitView{
                  anchors.fill: parent
                  orientation: Qt.Horizontal
                  }

                  }@

                  1 Reply Last reply
                  0
                  • J Offline
                    J Offline
                    Javeria
                    wrote on last edited by
                    #10

                    The C directory path is correct, but no view

                    1 Reply Last reply
                    0
                    • p3c0P Offline
                      p3c0P Offline
                      p3c0
                      Moderators
                      wrote on last edited by
                      #11

                      What do you mean by no view in this example?

                      157

                      1 Reply Last reply
                      0
                      • J Offline
                        J Offline
                        Javeria
                        wrote on last edited by
                        #12

                        View meaning that the image is not visible

                        1 Reply Last reply
                        0
                        • p3c0P Offline
                          p3c0P Offline
                          p3c0
                          Moderators
                          wrote on last edited by
                          #13

                          Ok. Try prepending file:// to source. And you can use "/" as file separator. Qt internally handles it depending upon OS.
                          @
                          iconSource: "file://C:/Users/Hassan Adil/Documents/sketchIt/16.png"
                          @

                          157

                          1 Reply Last reply
                          0
                          • J Offline
                            J Offline
                            Javeria
                            wrote on last edited by
                            #14

                            If i write file:/1.jpg which is located in C: it works and the view also works , but is it possible to put space between the images ?

                            1 Reply Last reply
                            0
                            • p3c0P Offline
                              p3c0P Offline
                              p3c0
                              Moderators
                              wrote on last edited by
                              #15

                              Ok. By space, do you mean another path ?

                              157

                              1 Reply Last reply
                              0
                              • J Offline
                                J Offline
                                Javeria
                                wrote on last edited by
                                #16

                                No i mean i want to have some distance between the images, to make it look good, can i use borders or something else?

                                1 Reply Last reply
                                0
                                • p3c0P Offline
                                  p3c0P Offline
                                  p3c0
                                  Moderators
                                  wrote on last edited by
                                  #17

                                  Inside the RowLayout you can set spacing.

                                  157

                                  1 Reply Last reply
                                  0
                                  • J Offline
                                    J Offline
                                    Javeria
                                    wrote on last edited by
                                    #18

                                    Okay thanks a lot!, and also how can i shift the listview close to the bottom of the window

                                    1 Reply Last reply
                                    0
                                    • p3c0P Offline
                                      p3c0P Offline
                                      p3c0
                                      Moderators
                                      wrote on last edited by
                                      #19

                                      anchor it to the bottom.

                                      157

                                      1 Reply Last reply
                                      0
                                      • J Offline
                                        J Offline
                                        Javeria
                                        wrote on last edited by
                                        #20

                                        I have tried to anchor it to the parent but the list view doesn't appear on the screen

                                        1 Reply Last reply
                                        0
                                        • p3c0P Offline
                                          p3c0P Offline
                                          p3c0
                                          Moderators
                                          wrote on last edited by
                                          #21

                                          and who is parent of ListView ?

                                          157

                                          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