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. Multiple widget in cells - design
Forum Updated to NodeBB v4.3 + New Features

Multiple widget in cells - design

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 2 Posters 676 Views 2 Watching
  • 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.
  • A Offline
    A Offline
    anyfun
    wrote on last edited by anyfun
    #1

    Hi everyone!

    I'm trying to build my first application based on Qt. I have discovered the whole pattern of Model/View/Delegate and I'm trying to build the application with the best Qt practices.

    I have unfortunately not found any topic that answers exactly my problem.

    I want to display information in a table with filters and with interactive content (all content is represented by text) in a specific column. By interactive, I mean : add text, delete text, modify text.
    It might be a mimic of these examples : Bootstrap tags Input

    Example

    My situation is the following :

    • AbstractTableModel (based on a Python dictionary & subclassed data(), rowCount(), columnCount(), flags(), headerData() and setData())
    • TableView
    • SortFilterProxyModel (subclassed filterAcceptsRow(), data())
    • StyledItemDelegate (on the specific column of the view)

    In my mind, I have two solutions:

    • Draw control in the cells and rewrite everything related to mouse event (click, double click and position in the cell). I would do it in the paint() subclassed function. The main problem here is the mouse handling but the performance would be great.

    • Insert widget (and buttons inside the widget) in a cell. I might be able to click in the widget (with a subclass widget) and to click buttons. However, the performance would be catastrophic (15k rows). Also, I feel like i'm breaking the Qt pattern and it is specifically mentionned that this solution should be used for static content only.

    Edit: I may have found a third solution:

    • Use the QAbstractItemView::openPersistentEditor() function with a createEditor from my delegate. Thus, no problem of widget generation (on editor creation) nor storage (transparent) but still problems of performance.

    Come the questions:

    • What's is the best way to achieve my project from a Qt pattern point of view?
    • If I go for the drawControl solution, how can i handle the position of the cursor from the cell perspective?
    • If I go for the Widget Insertion solution, where is the best place to store/create them (not in the delegate::paint() function obviously) ?

    Thank you for your reading and your time!

    1 Reply Last reply
    0
    • A Offline
      A Offline
      anyfun
      wrote on last edited by
      #4

      Hi everyone,

      Little update of my progress:

      • Using a persistent editor seems to be the best solution from my point of view
      • It is completly transparent from the creation in paint() (calling openPersistentEditor -> createEditor) to its destruction (calling closePersistentEditor provoking a re-opening and a redraw of the editor)
      • The editor, a custom widget, responds correctly after handling setModelData, updateEditorGeometry and editorEvent

      I'm still not sure that is the good way to proceed but it works fine.

      I'm closing the subject. Thanks for your reading.

      1 Reply Last reply
      1
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #2

        Hi and welcome to devnet,

        Not sure I'm following you correctly. Do you mean that you would like to have that kind of tag list inside cells of your table view ?

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

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

          Yes, it is exactly what i'm looking for.
          The table would have 15k rows with 10-15 tags per cell.

          Also, the tags have a variable length and the content is not predictible.

          1 Reply Last reply
          0
          • A Offline
            A Offline
            anyfun
            wrote on last edited by
            #4

            Hi everyone,

            Little update of my progress:

            • Using a persistent editor seems to be the best solution from my point of view
            • It is completly transparent from the creation in paint() (calling openPersistentEditor -> createEditor) to its destruction (calling closePersistentEditor provoking a re-opening and a redraw of the editor)
            • The editor, a custom widget, responds correctly after handling setModelData, updateEditorGeometry and editorEvent

            I'm still not sure that is the good way to proceed but it works fine.

            I'm closing the subject. Thanks for your reading.

            1 Reply Last reply
            1

            • Login

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