Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. International
  3. German
  4. QML Listview und delegate
Forum Updated to NodeBB v4.3 + New Features

QML Listview und delegate

Scheduled Pinned Locked Moved Unsolved German
2 Posts 2 Posters 432 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.
  • M Offline
    M Offline
    msauer75
    wrote on last edited by
    #1

    Hallo zusammen,

    ich versuche gerade die Elemente meiner Liste (in C++ definiert und mit Q_PROPERTY exportiert) in QML mittels Listview und model delegate horizontal anzuordnen. Allerdings wird nur das Erste Element angezeigt.

    Das Listview Element ist folgendermaßen definiert:

    Panel {
        property Cache cache
    
        width: parent.width*0.9
        height: 110
        x: 15
    
        contentComponent:
             ListView {
                id: itemsView
                clip: true
                width: parent.width
                height: 50
    
                model: cache.ui_attribute ? cache.ui_attribute : 0
                delegate: Attribute {
                    attributeDecorator: modelData
                }
            }
    }
    
    

    Das Delegate:

    Item {
        id: attr
        property AttributeDecorator attributeDecorator
        property string attrimage : (attributeDecorator.ui_value) ? "yes" : "no"
        property int widthValue
        property bool setWidthValue
    
        implicitWidth: parent.width
        implicitHeight: background.height
    
        //height: Style.heightDataControls
        //width: (setWidthValue) ? (widthValue+Style.widthDataControls) : (parent.width/2) - 10
    
        Component.onCompleted: {
            console.log("Attribute: ",attributeDecorator.ui_id, attributeDecorator.ui_value)
        }
    
        Rectangle {
            id: background
            width: parent.width
            height: 100
            color: Style.colourPanelBackground
    
            Image {
                id: image
                source: "http://www.geocaching.com/images/attributes/"+attributeDecorator.ui_id+"-"+attrimage+".gif"
            }
        }
    }
    
    

    Könnt ihr mir ein Tip geben warum die Images nicht nebeneinander dargestellt werden bzw. was muss ich da machen?

    Danke für Eure hilfe.

    gruss
    martin

    J.HilkJ 1 Reply Last reply
    0
    • M msauer75

      Hallo zusammen,

      ich versuche gerade die Elemente meiner Liste (in C++ definiert und mit Q_PROPERTY exportiert) in QML mittels Listview und model delegate horizontal anzuordnen. Allerdings wird nur das Erste Element angezeigt.

      Das Listview Element ist folgendermaßen definiert:

      Panel {
          property Cache cache
      
          width: parent.width*0.9
          height: 110
          x: 15
      
          contentComponent:
               ListView {
                  id: itemsView
                  clip: true
                  width: parent.width
                  height: 50
      
                  model: cache.ui_attribute ? cache.ui_attribute : 0
                  delegate: Attribute {
                      attributeDecorator: modelData
                  }
              }
      }
      
      

      Das Delegate:

      Item {
          id: attr
          property AttributeDecorator attributeDecorator
          property string attrimage : (attributeDecorator.ui_value) ? "yes" : "no"
          property int widthValue
          property bool setWidthValue
      
          implicitWidth: parent.width
          implicitHeight: background.height
      
          //height: Style.heightDataControls
          //width: (setWidthValue) ? (widthValue+Style.widthDataControls) : (parent.width/2) - 10
      
          Component.onCompleted: {
              console.log("Attribute: ",attributeDecorator.ui_id, attributeDecorator.ui_value)
          }
      
          Rectangle {
              id: background
              width: parent.width
              height: 100
              color: Style.colourPanelBackground
      
              Image {
                  id: image
                  source: "http://www.geocaching.com/images/attributes/"+attributeDecorator.ui_id+"-"+attrimage+".gif"
              }
          }
      }
      
      

      Könnt ihr mir ein Tip geben warum die Images nicht nebeneinander dargestellt werden bzw. was muss ich da machen?

      Danke für Eure hilfe.

      gruss
      martin

      J.HilkJ Online
      J.HilkJ Online
      J.Hilk
      Moderators
      wrote on last edited by
      #2

      hi @msauer75
      das erste was mir auffällt, ist dass du die Orientierung garnicht auf horizontal gestellt hast.

      orientation: ListView.Horizontal

      der Default ist Vertical.


      Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


      Q: What's that?
      A: It's blue light.
      Q: What does it do?
      A: It turns blue.

      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