Results 1 to 4 of 4

Thread: qtableview signal to model for internal drag and drop?

  1. #1
    Join Date
    Nov 2008
    Posts
    183
    Thanks
    13
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default qtableview signal to model for internal drag and drop?

    What signal should the model receive from a QTableView when an internal drag and drop has completed? I'm befuddled. I re-implemented dropMimeData() and set a break in it, but that never gets called and I wouldn't expect it to for an internal move. There has to be _something_ which gets sent back so the model can adjust what it sends for header data...or is this magic which happens only in the view and it does not communicate to the model? Ideally I need to know what the new column order is so I can save that for future use.

    A secondary, and not as important question: How does one actually block certain columns from being moved, especially having other internal columns moved around them? The result of flags() seems to be completely ignored when it comes to internal moves. Perhaps that is the nature of the beast?

    Thanks,
    Roland

  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 signal to model for internal drag and drop?

    Quote Originally Posted by RolandHughes View Post
    What signal should the model receive from a QTableView when an internal drag and drop has completed?
    Internal drag and drop is not done via signals. For a general drag and drop you should reimplement mimeTypes(), mimeData() and dropMimeData(). For internal drag and drop it could be that the view tries to simply call moveRows() on the model.

    I re-implemented dropMimeData() and set a break in it, but that never gets called and I wouldn't expect it to for an internal move. There has to be _something_ which gets sent back so the model can adjust what it sends for header data...or is this magic which happens only in the view and it does not communicate to the model? Ideally I need to know what the new column order is so I can save that for future use.
    Aren't you mixing two things? Internal drag and drop is not about repositioning columns in the view, it is about moving single items within the model. Repositioning columns in the view does not affect the model in any way.
    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
    Nov 2008
    Posts
    183
    Thanks
    13
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: qtableview signal to model for internal drag and drop?

    Aren't you mixing two things? Internal drag and drop is not about repositioning columns in the view, it is about moving single items within the model. Repositioning columns in the view does not affect the model in any way.
    That is _so_ not cool. If the view never communicates the repositioning of columns there is no way to save the user selected configuration across boots or navigations. As to "mixing", I don't know. I had to enable internal drag and drop on the header in order to move columns.

    Internal drag and drop is not done via signals. For a general drag and drop you should reimplement mimeTypes(), mimeData() and dropMimeData(). For internal drag and drop it could be that the view tries to simply call moveRows() on the model.
    Thanks. I will look for moveColumns() and see if it actually gets called. There has to be _some_ way of preserving the user selected column order across instantiations of the tableview.

  4. #4
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: qtableview signal to model for internal drag and drop?

    Quote Originally Posted by RolandHughes View Post
    That is _so_ not cool. If the view never communicates the repositioning of columns there is no way to save the user selected configuration across boots or navigations.
    Why would that not be possible?
    All the necessary information is available at the source (for moved columns the vertical header view).

    Quote Originally Posted by RolandHughes View Post
    As to "mixing", I don't know.
    While the user interaction is quite similar, the result is not.
    A drag&drop of items changes the structure of the model (shared between all views on that model), a drag&drop of header sections changes the way this particular view displays the data (specific to that view).

    Quote Originally Posted by RolandHughes View Post
    I had to enable internal drag and drop on the header in order to move columns.
    You mean QHeaderView::setSectionsMovable()?


    Quote Originally Posted by RolandHughes View Post
    Thanks. I will look for moveColumns() and see if it actually gets called. There has to be _some_ way of preserving the user selected column order across instantiations of the tableview.
    Also have a look at http://qt-project.org/doc/qt-5/qhead...l#sectionMoved

    Cheers,
    _

Similar Threads

  1. QListView/QAbstractItemView and list internal drag & drop
    By Infinity in forum Qt Programming
    Replies: 1
    Last Post: 15th June 2014, 17:37
  2. QTableWidget Internal Drag/ Drop Entire Row
    By davethomaspilot in forum Newbie
    Replies: 0
    Last Post: 16th December 2012, 01:31
  3. Replies: 1
    Last Post: 6th April 2011, 08:24
  4. Replies: 2
    Last Post: 13th October 2010, 22:51
  5. Drag drop internal
    By valgaba in forum Qt Programming
    Replies: 0
    Last Post: 30th September 2010, 15:49

Tags for this Thread

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.