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. Menu instantiator's starange bechaviour when remove tems from model
Qt 6.11 is out! See what's new in the release blog

Menu instantiator's starange bechaviour when remove tems from model

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

    This is crosspost from "stackoverflow":http://stackoverflow.com/questions/19124156/qtquick-menu-instantiator-notify-about-changed-rows.

    I have menu items model and Instantiator for it.

    @Menu {
    id: backContextMenu
    Instantiator {
    model: backModel
    MenuItem {
    text: model.text
    }
    onObjectAdded: {
    console.log("QML: object added: " + object.text + ", index= " + index);
    backContextMenu.insertItem(index,object)
    }
    onObjectRemoved: {
    backContextMenu.removeItem(object)
    console.log("QML: object removed: " + object.text);
    }
    }
    }@

    When I add any item to model at index 0 signal objectAdded is emitted with new MenuItem and index=0 as expected. But if I want to drop some items from model (for example, I have ["a";"b";"c";"d"] in model and want to remove "a" and "b") menu items are dropped from another side ("c" and "d" are dropped, "a" and "b" are still alive). After some hacking I found workaround: If I remove n items from the beginning of model I should write

    @beginRemoveRows(QModelIndex(), _items.count()-n, _items.count()-1);@

    instead of

    @beginRemoveRows(QModelIndex(), 0, n-1);@

    Any ideas why items are removed from another side? I have "demo":https://github.com/Kakadu/qtquick_test_instantiator for you.

    1 Reply Last reply
    0
    • K Offline
      K Offline
      Kakadu
      wrote on last edited by
      #2

      I have created patch for this "bug":https://bugreports.qt-project.org/browse/QTBUG-33847

      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