Results 1 to 13 of 13

Thread: [qt-4.2] question on QAbstractItemView

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    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: [qt-4.2] question on QAbstractItemView

    But why create an own view? You have to use the scrollTo() method, not reimplement it.

  2. #2
    Join Date
    Dec 2006
    Posts
    31
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: [qt-4.2] question on QAbstractItemView

    Thanks, I managed to do scrollTo. But it came out not quite the way I wanted.
    For example we have the list:
    item_1
    item_2
    item_3
    item_4
    item_5
    item_6
    item_7
    item_8
    only 5 items fit into QListView list in my app, so after launch my ListView should look like this:
    ---------------------------
    | item_7 |
    | item_8 |
    |--------------------------|
    | item_1 |
    |--------------------------|
    | item_2 |
    | item_3 |
    ---------------------------|

    So the list must croll around and the central item should stay in the middle unmovable. How do I do it?
    May be
    void QListView::indexesMoved ( const QModelIndexList & indexes ) [signal]
    void QListView::setPositionForIndex ( const QPoint & position, const QModelIndex & index ) [protected]
    Or is there any other way? Please help.

  3. #3
    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: [qt-4.2] question on QAbstractItemView

    Quote Originally Posted by someralex View Post
    So the list must croll around and the central item should stay in the middle unmovable.
    Oh, you didn't mention that "detail" before

    How do I do it?
    Good question The easiest way is to add additional items. The proper way is probably to subclass the view and reimplement the painting and positioning routines.

  4. #4
    Join Date
    Dec 2006
    Posts
    31
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: [qt-4.2] question on QAbstractItemView

    The easiest way is to add additional items.
    Where should I add the additional items? Into the model? How do I do that?
    The proper way is probably to subclass the view and reimplement the painting and positioning routines.
    and what routines exactly I need to reimplement in the created class, based on QListView?

  5. #5
    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: [qt-4.2] question on QAbstractItemView

    Quote Originally Posted by someralex View Post
    Where should I add the additional items? Into the model? How do I do that?
    Hmm... the same way you added the original items?

    and what routines exactly I need to reimplement in the created class, based on QListView?
    At least the paint event and visualRect.

Similar Threads

  1. QThread exit()/quit() question
    By TheKedge in forum Qt Programming
    Replies: 1
    Last Post: 28th August 2006, 14:38
  2. setContentsMargins in QAbstractItemView
    By Promethee in forum Qt Programming
    Replies: 2
    Last Post: 4th February 2006, 14:40

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.