Results 1 to 12 of 12

Thread: Moving items between two views.

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    travelling
    Posts
    1,116
    Thanks
    8
    Thanked 127 Times in 121 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Moving items between two views.

    Quote Originally Posted by YuriyRusinov View Post
    These views have to be contains single items set, but every item have to be contained in one and only one view. Before this I do it using available model and selected model. This approach results in very slow time in interaction. Now I try to another approach to have single source model and different list of displayed data.
    Well I suggest you add a flag/property/whatever-you-name-it to your items which will define in which view it shall be displayed. Then each view will be fed by a proxy which will display only items with the matching flag. This flag can be any type for which it exists comparisions operators (QString, QChar, QPoint, ...) but an integer is probably the best solution if you're looking for speed.

    Then moving an item from a view to another will be as simple as :
    • changing the aforementionned flag
    • notifying a change to the view (either a dataChanged(parentIndex, parentIndex) or a complexer but possibly more efficient computation and {begin,end}{Insert,Remove}Rows()...)
    Current Qt projects : QCodeEdit, RotiDeCode

  2. The following user says thank you to fullmetalcoder for this useful post:

    YuriyRusinov (3rd April 2007)

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

    Default Re: Moving items between two views.

    If both views don't share any data from the model (for example one displays all odd rows and the other all even rows), then I'd say it might be better to have two separate source models. But it is hard to make that a rule of thumb.

  4. The following user says thank you to wysota for this useful post:

    YuriyRusinov (3rd April 2007)

Similar Threads

  1. GraphicsView performance problems
    By Gopala Krishna in forum Qt Programming
    Replies: 79
    Last Post: 8th August 2007, 17:32
  2. Moving multiple QGraphicItems
    By StefanHirche in forum Newbie
    Replies: 2
    Last Post: 11th January 2007, 21:27
  3. Drag Drop between Different Views
    By aamer4yu in forum Qt Programming
    Replies: 13
    Last Post: 8th December 2006, 04:29
  4. Selective highlighting of Items
    By Kapil in forum Qt Programming
    Replies: 3
    Last Post: 26th May 2006, 12:20
  5. moving Qlistview items
    By :db:sStrong in forum Qt Programming
    Replies: 0
    Last Post: 21st February 2006, 12:25

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
  •  
Qt is a trademark of The Qt Company.