Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Which models support moving of rows/columns
Forum Update on Monday, May 27th 2025

Which models support moving of rows/columns

Scheduled Pinned Locked Moved General and Desktop
5 Posts 2 Posters 1.1k 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.
  • W Offline
    W Offline
    Wurgl
    wrote on last edited by
    #1

    Hello!

    When I look at the documentation,
    http://doc.qt.io/qt-5/qabstractitemmodel.html#moveColumn
    I see a statement "On models that support this, ..." and I am wondering which models do support moving?

    Or how can I subclass a model to support moving rows?

    There is no example in the distribution, at least I (say: grep) did not find moveRow in any.

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      AFAIK there's currently none implementing it.

      As for subclassing, just reimplement the corresponding method and modify your data structure following that. There's not really much more than that.

      Do you have a specific use case ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • W Offline
        W Offline
        Wurgl
        wrote on last edited by
        #3

        Well, I did it home grown in some QTreeView with a QStandardItemModel simple by recursivly collecting all expanded child items of that part which I want to move, the remove the rows, insert them and restore the expand-status.

        But since home grown code usually has more errors than some library I was wondering if there is some model, some example supporting this already.

        In addition: moveRow is not virtual, just moveRows is. This is a little bit confusing.

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          it's because moveRow is just a special case of calling moveRows for one row.

          Anyway, there's something not clear, your talking once about moveColumn then moveRow, which one is it ?

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • W Offline
            W Offline
            Wurgl
            wrote on last edited by
            #5

            Oops, moveRow. And as I said, I have a working implementation. I am just asking.

            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