Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to creat a different height editer from it’s item In a QItemDelegate?
QtWS25 Last Chance

How to creat a different height editer from it’s item In a QItemDelegate?

Scheduled Pinned Locked Moved General and Desktop
3 Posts 3 Posters 3.5k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • F Offline
    F Offline
    fuqq
    wrote on last edited by
    #1

    i am work on creat a SlippingItemView view by delegate.

    The slipping UI like:
    @


    item1


    |item2 editer |
    |(different height) |


    item3 <--this be covered
    ...


    @

    QItemDelegate show editer on item clicked , QItemDelegate::paint() reimplemented to draw the item , QItemDelegate::creatEditer() reimplemented to show a different height editer.

    It is easy to creat a different height editer by reimplemented QItemDelegate::updateEditorGeometry() , but the item sizehint will not change . Problem is editer will cover the sibling item (for example: item3).

    Question : Is there any way to update item sizehint to it's editer , and resume normal height when editer closed?

    1 Reply Last reply
    0
    • M Offline
      M Offline
      mariusbu
      wrote on last edited by
      #2

      You want to reimplement the "QItemDelegate::sizeHint()":http://doc.qt.nokia.com/4.6/qitemdelegate.html#sizeHint function to return a different size if the item is being edited. You probably have to keep track of which items are being edited and make sure you update the layout of the items in the view when you update their sizes. You probably want to have a look at the "QAbstractItemView":http://doc.qt.nokia.com/4.6/qabstractitemview.html. Happy Hacking! :)

      Cheers,
      Marius Bugge Monsen (mbm)

      1 Reply Last reply
      0
      • A Offline
        A Offline
        andre
        wrote on last edited by
        #3

        I fear it may not turn out to be easy. For instance QTableView does not listen at all to the size hint, and QListView only uses changes in the size hint if QListView::isWrapping is true. That does not mean that views, especially QListView, do not query for the size hint. They do, but they don't seem to use the result.

        I tried to use the QAbstractItemDelegate::sizeHintChanged signal to let the view know about a needed re-layout, but in my tests (by reimplementing QObject::connectNotify in the delegate), I could not see that signal actually being connected to by the views.

        Sorry to give you such negative experiences only, but I don't want you to get your hopes up too high. It me, it seems that the item views still lack a lot of optimization, documentation and polish.

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved