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. Has anybody tried the new 'QAbstractItemModel::moveRow(...)' in Qt5 already?
Forum Updated to NodeBB v4.3 + New Features

Has anybody tried the new 'QAbstractItemModel::moveRow(...)' in Qt5 already?

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

    There is a new function in Qt5:

    @bool QAbstractItemModel::moveRow(const QModelIndex & sourceParent, int sourceRow, const QModelIndex & destinationParent, int destinationChild)@

    Has anybody tried it already and was successful?

    The doc file says: "On models that support this, moves sourceRow from sourceParent to destinationChild under destinationParent." but nothing about which models are supporting this function.

    I've tried it with

    @tableModel->moveRow ( tableView->currentIndex(),
    tableView->currentIndex().row(),
    tableView->currentIndex(),
    tableView->currentIndex().row() +2 );@

    No problem to compile but when I'm calling this function with qDebug(), it returns 'false' only and that's all.

    Any ideas?

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

      Hi and welcome to devnet,

      AFAIK, moveRow is currently only implemented in QAbstractItemModel and does nothing.

      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
      1
      • G Offline
        G Offline
        gboelter
        wrote on last edited by
        #3

        Thanks SGaist!

        It's not the answer I like, specially where I have spent at least two hours to get it working, but I guess you are right ...

        I really should not try new things after midnight when I'm tired. ;-)

        1 Reply Last reply
        0
        • A Offline
          A Offline
          Andre Soeiro
          wrote on last edited by
          #4

          Hi all,
          seems like this is a rather old topic, but I would like to bring it up again, since I am also in the need of these functions.

          Am I right to assume that we need to implement the moveRow and moveRows methods in our models in order to get these functions working?

          Thanks in advance,
          Andre

          1 Reply Last reply
          0
          • VRoninV Offline
            VRoninV Offline
            VRonin
            wrote on last edited by
            #5

            Only moveRows but yes

            "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
            ~Napoleon Bonaparte

            On a crusade to banish setIndexWidget() from the holy land of Qt

            1 Reply Last reply
            2

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved