Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-60226

Provide easy way to add widgets to views

    XMLWordPrintable

Details

    • Suggestion
    • Resolution: Unresolved
    • P5: Not important
    • None
    • None
    • Widgets: Itemviews
    • None

    Description

      Hi,

      Imagine this usecase. You have a model with an x number of columns. One (or more) of these columns need to be a widget. For instance a QPushButton. It's not a really exotic usecase and i've been through that case a couple of times. The way this is currently possible in views (say QTableView) is really non-intuitive and requires a lot of boiler plate code. That in turn makes it very error prone and difficult to develop.

      Qt's delegate options for this aren't suffice. The only one provided by Qt is QAbstractItemDelegate and that doesn't help showing a widget. Others that are possible (but require a lot of code to work with any widget) are QItemDelegate and (if you want to code even more) QAbstractItemDelegate.

      I'd like to request a delegate that easily allows you to show any widget including it's interaction (say mouse hovers and clicks on a QPushButton) to be provided by Qt with minimal code. For reference, see the far from trivial star delegate from Qt itself: http://doc.qt.io/qt-5/qtwidgets-itemviews-stardelegate-example.html

      This new delegate (lets call it QWidgetDelegate) is going to pose a bit of a challenge. For instance, how would you bind the clicked or pressed or any signals from - for example - QPushButton to an action defined by the user.

      Thanks,
      Mark

      Attachments

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              qt.team.quick.subscriptions Qt Quick and Widgets Team
              markg85 Mark
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:

                Gerrit Reviews

                  There are no open Gerrit changes