Results 1 to 6 of 6

Thread: QTableView and changing row order in model by dragging them

  1. #1
    Join Date
    Nov 2008
    Posts
    27
    Qt products
    Qt4
    Platforms
    Windows

    Default QTableView and changing row order in model by dragging them

    I need to change order of data elements themselves. How can i do this?

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QTableView and changing row order in model by dragging them

    Enable "InternalMove" dragDropMode for the view.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Feb 2010
    Location
    Sydney, Australia
    Posts
    111
    Thanks
    18
    Thanked 5 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QTableView and changing row order in model by dragging them

    Enabling "InternalMove" does not make it possible to change the order of elements in a table. In fact it seems to have no effect whatsoever.

    I have a custom model (inherited from QAbstractListModel) and use a QTableView to view the data. I would like to be able to reorder the columns by dragging and dropping them.

    Does anyone know how to achieve this?

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QTableView and changing row order in model by dragging them

    Quote Originally Posted by stefanadelbert View Post
    Enabling "InternalMove" does not make it possible to change the order of elements in a table. In fact it seems to have no effect whatsoever.
    Did you implement means for changing the model (i.e. setData(), insertRows(), removeRows())?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. #5
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: QTableView and changing row order in model by dragging them

    Quote Originally Posted by stefanadelbert View Post
    I have a custom model (inherited from QAbstractListModel) and use a QTableView to view the data. I would like to be able to reorder the columns by dragging and dropping them.
    If you want the column (row) display order to be changeable by drag and drop of the column (row) headers then you need to look at QHeaderView::setMovable(). Wysota's suggestion is to do with moving data about within the model underlying the view (using drag and drop on the view).

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QTableView and changing row order in model by dragging them

    I was addressing the "changing row order in model" issue.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. Changing column order in QTableView
    By Banjo in forum Qt Programming
    Replies: 1
    Last Post: 18th January 2008, 06:49

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.