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. QAbstractItemModel::rowsMoved signal behavior
Forum Updated to NodeBB v4.3 + New Features

QAbstractItemModel::rowsMoved signal behavior

Scheduled Pinned Locked Moved Solved General and Desktop
9 Posts 2 Posters 903 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.
  • H Offline
    H Offline
    hbatalha
    wrote on last edited by
    #1

    So I have a method from a class that inherits from QListWidget that is connected to QAbstractItemModel::rowsMoved signal.

    void PlaylistPage::onRowsMoved(const QModelIndex &, int start, int end, const QModelIndex &, int row)
    {
             for(int i = start; i <= end; i++)
            {        
               // some code
            }
    }
    

    According to the doc:

    This signal is emitted after rows have been moved within the model. The items between start and end inclusive, under the given parent item have been moved to destination starting at the row row.

    I was expecting that once I moved the rows the method would be called only once but I came to find that when I am moving multiple rows the method will be called as many times as the number of the rows moved. In each call the value of start and end are always the same.

    So I was wondering if I interpreted the doc right. Are the values of end and start always the same in each call?

    1 Reply Last reply
    0
    • Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      What Qt version do you use? How do you move the rows?

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      H 1 Reply Last reply
      0
      • Christian EhrlicherC Christian Ehrlicher

        What Qt version do you use? How do you move the rows?

        H Offline
        H Offline
        hbatalha
        wrote on last edited by
        #3

        @Christian-Ehrlicher Qt 5.15.2

        Christian EhrlicherC 1 Reply Last reply
        0
        • H hbatalha

          @Christian-Ehrlicher Qt 5.15.2

          Christian EhrlicherC Offline
          Christian EhrlicherC Offline
          Christian Ehrlicher
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @hbatalha

          How do you move the rows?

          Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
          Visit the Qt Academy at https://academy.qt.io/catalog

          H 1 Reply Last reply
          1
          • Christian EhrlicherC Christian Ehrlicher

            @hbatalha

            How do you move the rows?

            H Offline
            H Offline
            hbatalha
            wrote on last edited by
            #5

            @Christian-Ehrlicher Drag and drop

            1 Reply Last reply
            0
            • Christian EhrlicherC Offline
              Christian EhrlicherC Offline
              Christian Ehrlicher
              Lifetime Qt Champion
              wrote on last edited by
              #6

              The default dnd implementation moves every row by it's own.

              Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
              Visit the Qt Academy at https://academy.qt.io/catalog

              H 1 Reply Last reply
              1
              • Christian EhrlicherC Christian Ehrlicher

                The default dnd implementation moves every row by it's own.

                H Offline
                H Offline
                hbatalha
                wrote on last edited by
                #7

                @Christian-Ehrlicher So are the values of end and start always the same in each call?

                1 Reply Last reply
                0
                • Christian EhrlicherC Offline
                  Christian EhrlicherC Offline
                  Christian Ehrlicher
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  When every row is moved by it's own then start and end must be the same since... only one row is moved.

                  Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                  Visit the Qt Academy at https://academy.qt.io/catalog

                  H 1 Reply Last reply
                  1
                  • Christian EhrlicherC Christian Ehrlicher

                    When every row is moved by it's own then start and end must be the same since... only one row is moved.

                    H Offline
                    H Offline
                    hbatalha
                    wrote on last edited by
                    #9

                    @Christian-Ehrlicher Ok Thank you for the clarification

                    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