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. ItemDelegate vs ProxyModel Subclass
Forum Updated to NodeBB v4.3 + New Features

ItemDelegate vs ProxyModel Subclass

Scheduled Pinned Locked Moved General and Desktop
3 Posts 3 Posters 843 Views 1 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.
  • dionis.D Offline
    dionis.D Offline
    dionis.
    wrote on last edited by
    #1

    I'm have to create a form where some questions will be taken from the db. Each question will have two radioButtons (Yes / No), a label "Explain..." and a textEdit. Firstly I created this in a QScrollArea, where for every question in the db (taken with QSqlTableModel) all the necessary widget were created and put into the layouts.

    Now I think I would better do it in a QListView, where an item will be all the question = its information (question + 2 radioButtons + label + textEdit + its Layouts). I thought I could easily do it with QAbstractItemDelegate, so I created a subclass for it, but I am having some problems though. The question are not shown at all, even are its informations. Should I use a subclass of ProxyModel instead? I found a very useful checkableProxyModel! subclass which added a checkbox for every item in a model, and I thought if it was possible to add a checkBox, maybe it is possible to add all this information?

    Any idea?

    Comment if you need any code.

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

      Hi and welcome to devnet,

      If you need custom painting like it seems, then go with QStyledItemDelegate.

      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
      0
      • A Offline
        A Offline
        andre
        wrote on last edited by
        #3

        I'd advise against using the item views system for this. It seems you need complete widgets. The checkbox that is available via the CheckableProxyModel is rendered by the item view framework itself. It is not a real widget, it just uses the rendering code for one. I know, because I write the class. It doesn't do anything else than Qt models can all do by setting the right item roles and flags.

        Widgets in item views are generally not a good idea. Item views are simply not designed to do that.

        What you could do, is use Qt Quick for this instead. Quicks item views are designed to be able to contain everything you want, and Quick now supplies you with Quick Controls. That means that making a delegate that is just a mini-form is easy, and you can show one for every item in your model. Quick can also be embedded (again) in widget-based applications, so even if you have more widget-based code already, it may still be an option.

        Otherwise: go for your scroll-view based solution.

        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