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. Different editor widgets in QStyledItemDelegate
Qt 6.11 is out! See what's new in the release blog

Different editor widgets in QStyledItemDelegate

Scheduled Pinned Locked Moved General and Desktop
qstyleditemdeleqtreeview
2 Posts 2 Posters 1.1k 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
    abstracted8
    wrote on last edited by
    #1

    I'm attempting to create a "property editor" type widget analogous to the one in the Qt Designer.

    The issue I am facing is how to handle the creation of different editor widgets in the "value" column, depending on the expected input type. I.e. QDoubleSpinBox for decimal input, QComboBox for selection from a list, etc.

    I began trying to implement this capability through subclassing QStyledItemDelegate (overriding QStyledItemDelegate.createEditor()) and setting the delegate in my QTreeView. I can find plenty of examples for this procedure when setting the same widget for an entire column. However, I cannot seem to extrapolate from these examples to set widgets in the "value" column depending on the data in the "property column".

    I'll try to graphically show below what I want.

    Hopefully someone can point me in the right direction, thanks.

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

      Hi,

      In the createEditor function you should query the type of what you are going to show and based on that return the corresponding widget.

      Hope it helps

      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

      • Login

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