Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for Python
  4. QAbstractListmodel / ListView manual positioning
Forum Updated to NodeBB v4.3 + New Features

QAbstractListmodel / ListView manual positioning

Scheduled Pinned Locked Moved Unsolved Qt for Python
1 Posts 1 Posters 353 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.
  • D Offline
    D Offline
    dadara
    wrote on last edited by
    #1

    In a ListView in qml, which uses the data model from a QAbstractListModel, I am trying to position the items (Rectangles) manually with data from the Model. This works in the beginning when I add the items but when I delete a ListItem the items get shifted upwards?
    This is the qml:
    ListView {
    id: ces_cal_markers_list
    objectName: "ces_cal_markers_list"
    anchors.left: ces_ftuc_img.left
    anchors.top: ces_ftuc_img.top
    x: grid_x
    y: grid_y
    z: 2
    interactive: true
    width: ces_ftuc_img.width
    height: ces_ftuc_img.height
    // orientation: ListView.Vertical
    model: ces_ftuc_service

        populate: Transition {
            id: dispTrans
            NumberAnimation { properties: "y"; duration: 1000 }
        }
    
        delegate:
            Rectangle {
                objectName: calib_id
                width: 30;
                height: 30;
                radius: width/2
                x: calib_x*ces_ftuc_img.width
                anchors.top: parent.top
                anchors.topMargin: calib_y*ces_ftuc_img.height
                color: calib_color; opacity: 0.3; border{color: "black"; width: 3 }
            }
    }
    

    deleting in subclass of QAbstractListModel in python:
    def delete_calib_sample(self, row):
    self.beginRemoveRows(QModelIndex(), row, row)
    del self.calib_samples[row]
    self.endRemoveRows()

    calib_x, calib_y are the values of the list model used for positioning. Someone has an idea why the items shift after deleting an item or how I can override the automatic positioning of ListViews?
    thanks in advance

    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