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. [SOLVED] Multiple item delegates in QTreeWidget
Forum Updated to NodeBB v4.3 + New Features

[SOLVED] Multiple item delegates in QTreeWidget

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 2.2k 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.
  • X Offline
    X Offline
    xcoder
    wrote on last edited by
    #1

    Hello everyone,

    I was wondering, whether it is possible to have multiple item delegate types, like for one column a QComboBox and for the other one QSpinBox?

    Well if it's not, no big deal, I have already added a QComboBox widget to one of the columns, it just would be nicer to have an editor pop up on double click.

    Kind Regards
    Raivis

    Only a biker knows why a dog sticks his head out of a car window.

    1 Reply Last reply
    0
    • raven-worxR Offline
      raven-worxR Offline
      raven-worx
      Moderators
      wrote on last edited by
      #2

      you can use QAbstractItemView::setItemDelegateForColumn()
      But for this purpose 1 delegate should be also fine. Just create your editor widget depending on the column index.

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      1 Reply Last reply
      0
      • X Offline
        X Offline
        xcoder
        wrote on last edited by
        #3

        Thank you!

        I went for 1 delegate approach, where I'm checking the column, and create the delegate accordingly. Works like a charm. Somehow didn't occur to me, that it could be this simple.

        Only a biker knows why a dog sticks his head out of a car window.

        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