Results 1 to 4 of 4

Thread: TableView Delegate questions

  1. #1
    Join Date
    Nov 2006
    Posts
    35
    Thanks
    25
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Question TableView Delegate questions

    1. I implemented QItemDelegate to create some custom widget to edit data from my custom model. How can I get the QTableView to display this editor delegate even if the user is not editing the cell?
    In the Qt Icons Example openPersistentEditor(item) is used. But I want to have this behaviour for one column/the delegate. Is there another way to do this?

    2. How can I call resizeRowToContents(int) when the editor delegate is shown (to make the cell fit the editor widget size) and after the editor is deleted? I would like the tableView resize dynamically when showing the editor.

    Thanks in advance,
    -Jens

  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: TableView Delegate questions

    Quote Originally Posted by No-Nonsense View Post
    1. I implemented QItemDelegate to create some custom widget to edit data from my custom model. How can I get the QTableView to display this editor delegate even if the user is not editing the cell?
    In the Qt Icons Example openPersistentEditor(item) is used. But I want to have this behaviour for one column/the delegate. Is there another way to do this?
    openPersistentEditor will open an editor provided by the delegate. Alternatively you could make a "snapshot" of the editor and render the snapshot instead of the actual widget when the user is not editing the item.

    2. How can I call resizeRowToContents(int) when the editor delegate is shown (to make the cell fit the editor widget size) and after the editor is deleted? I would like the tableView resize dynamically when showing the editor.
    This is not really a good idea. It is the editor which should integrate nicely into the existing layout, not vice versa. If you really want such a behaviour, you'll have to store a pointer to QTableView while creating the editor (the parent of the editor will be the viewport and the parent of the viewport should be the view).

  3. #3
    Join Date
    Nov 2006
    Posts
    35
    Thanks
    25
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: TableView Delegate questions

    Quote Originally Posted by wysota View Post
    openPersistentEditor will open an editor provided by the delegate. Alternatively you could make a "snapshot" of the editor and render the snapshot instead of the actual widget when the user is not editing the item.
    Is there another way to show the persistent editor than calling openPersistentEditor for every index in the collumn? Does the View keep track of the cells in view and opens/closes the editors as needed or does all the persistent editors stay open? This would result in rowCount widgets being created...

    How would I make a snapshot and render it? Rendering would be done in the paint method of my delegate?

    Quote Originally Posted by wysota View Post
    This is not really a good idea. It is the editor which should integrate nicely into the existing layout, not vice versa. If you really want such a behaviour, you'll have to store a pointer to QTableView while creating the editor (the parent of the editor will be the viewport and the parent of the viewport should be the view).
    The problem is that the custom widget to show inside the cell consists of 16 checkboxes layouted 2x8. They simply do not fit the cell height. Should I show an editing dialog instead?

    Thanks in advance,
    -Jens

  4. #4
    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: TableView Delegate questions

    Quote Originally Posted by No-Nonsense View Post
    Is there another way to show the persistent editor than calling openPersistentEditor for every index in the collumn? Does the View keep track of the cells in view and opens/closes the editors as needed or does all the persistent editors stay open? This would result in rowCount widgets being created...
    Persistent editors are called persistent, because they are... persistent - so all open editors will stay open. What do you need a persistent editor for if you don't want it to be persistent? Maybe you can use a regular editor instead?

    How would I make a snapshot and render it?
    Just grab a pixmap from the editor before it is closed and render it or use QStyle if you wish to use one that composes from default widgets as your editor.

    Rendering would be done in the paint method of my delegate?
    Yes.

    The problem is that the custom widget to show inside the cell consists of 16 checkboxes layouted 2x8.
    So?

    They simply do not fit the cell height. Should I show an editing dialog instead?
    If the editor is complex then better use a separate dialog. You'll avoid cluttering the view.

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

    No-Nonsense (14th December 2006)

Similar Threads

  1. TreeView, TableView
    By rbrand in forum Qt Programming
    Replies: 1
    Last Post: 4th July 2006, 09:54
  2. Modified tableview
    By dkite in forum Qt Programming
    Replies: 2
    Last Post: 14th March 2006, 02:58
  3. 2 Questions about layouts
    By SkripT in forum Qt Programming
    Replies: 1
    Last Post: 26th February 2006, 14:54
  4. Qt related questions and thoughts about getting job
    By AlexKiriukha in forum General Discussion
    Replies: 4
    Last Post: 26th January 2006, 13: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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.