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. using pixmaps as an alternative to openPersistentEditor() in an itemView

using pixmaps as an alternative to openPersistentEditor() in an itemView

Scheduled Pinned Locked Moved General and Desktop
modelvieweditordelegate
2 Posts 2 Posters 1.1k 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.
  • M Offline
    M Offline
    mortbopet
    wrote on 15 Oct 2017, 12:56 last edited by
    #1

    I have an item view where my editor, as dictated by my delegate, is identical to the way the item is painted in the view, when not being edited. Imagine having, inside an. tableView item, a composite widget with a lineedit, 2 QDials, some buttons etc. It is this widget that should be both the editor but also the persistent display of the item.

    I am looking for the best way to draw a lot of these widgets (the view will be in a scroll area), and i could have up to maybe 600 of these widgets open at once. Because the number of potential widgets is quite high, i dont see setIndexWidget() as being the right solution. The same goes for openPersistentEditor().

    My current idea is to use grab() on the editor when editing has finished, and save the pixmap. Then, whenever the delegate needs to paint the item, it is this pixmap that is drawn - instead of redrawing actual widgets. Without having implemented this, i imagine that this should be a lot more efficient than having hundreds of active widgets.
    This solution would therefore mean that only selected items will have an editor drawn for them, whilst all other items will have a pixmap drawn, that looks identical to the editor.

    I wanted to get some input on whether this is a good solution, or if i'm missing something obvious.

    Best regards

    1 Reply Last reply
    0
    • C Offline
      C Offline
      Chris Kawa
      Lifetime Qt Champion
      wrote on 15 Oct 2017, 18:46 last edited by
      #2

      I'm doing something similar in sort of objects property tree. It works pretty well for large number of items. Definitely a massive win over a widget per item approach.
      One difference to your approach is that I don't use grab(), but instead have the editors created by the delegate a static drawing function that uses QStyle::drawControl and friends to draw an image of itself. This is because I don't want to instantiate all the editor widgets upfront to grab them (I have a bunch of them and it takes time). It's sort of a trade-off because it can get out of sync with the actual widget look. Whether this is something you'd be interested in or not is up to you, but the general idea of drawing an image is a valid one.

      1 Reply Last reply
      2

      1/2

      15 Oct 2017, 12:56

      • Login

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