Results 1 to 11 of 11

Thread: QListView and column moving

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #7
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QListView and column moving

    Quote Originally Posted by gadnio
    So, how the hell can i swap/move columns without iterating through all the items and swapping text as a mad one (that is stupid and slow enough, i want the operation to be faster).
    First of all, try disabling updates (using QWidget::setUpdatesEnabled()) while you switch columns. This should reduce the flicker.

    Another way you could try requires subclassing QListViewItem. You will also need a mapping that maps logical columns (those which you use in your program) to physical ones (those that are visible in the view). This map should be shared among all items.

    Now YourViewItem::paintCell() should be somthing like this:
    Qt Code:
    1. void YourViewItem::paintCell ( QPainter * p, const QColorGroup& cg, int column, int width, int align )
    2. {
    3. QListViewItem::paintCell( p, cg, _map[ column ], width, align );
    4. }
    To copy to clipboard, switch view to plain text mode 
    Probably you will have to change other methods too (AFAIR similar solution was discussed at QtForum).

    Now if you want to switch columns, all you have to do is to update the map and redraw QListView contents.

    You could also experiment with drag & drop mechanism (something tells me that you can use it to switch columns, but I'm not sure if it works).
    Last edited by jacek; 5th January 2006 at 14:42.

Similar Threads

  1. Subclass QListView to show two colums in one
    By Mookie in forum Qt Programming
    Replies: 2
    Last Post: 23rd June 2007, 02:12
  2. Replies: 0
    Last Post: 10th November 2006, 13:46
  3. Editable QListView Column ??
    By darpan in forum Qt Programming
    Replies: 1
    Last Post: 3rd May 2006, 18:55
  4. hidden QListView column suddenly visible
    By edb in forum Qt Programming
    Replies: 10
    Last Post: 27th January 2006, 08:00

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.