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. Custom editor for QListView
Forum Updated to NodeBB v4.3 + New Features

Custom editor for QListView

Scheduled Pinned Locked Moved General and Desktop
qlistvieweditdelegate
3 Posts 2 Posters 1.9k 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.
  • M Offline
    M Offline
    Moschops
    wrote on 6 May 2015, 11:31 last edited by
    #1

    I have an existing QListView. Currently, double-clicking on a cell allows the user to edit the contents of that cell, and I see the change get committed to the model behind the view.

    I need more control over that edit capability; rather than let the user simply type something, I want to open a widget to make them select a directory, and commit that (as a string) to the model. Making that is no problem; what I can't figure out is how to have the double-clicking action open my selection widget.

    I'm digging around, and I find the function QAbstractItemView::edit that looks like what I want to override? Presumably I will need to create a new class, inheriting from QListView, and override edit in that subclass? Is there another way? I was looking at delegates but I can't work out from the documentation if there is a way to direct a QListView to use something I provide for editing.

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 6 May 2015, 22:03 last edited by
      #2

      Hi,

      You should implement a QStyledItemDelegate, that way you can provide your custom editor.

      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
      • M Offline
        M Offline
        Moschops
        wrote on 7 May 2015, 10:53 last edited by
        #3

        I did figure it out in the end, mostly. The QT documentation is a good reference guide but as something to learn from, it's a bit rough. :(

        1 Reply Last reply
        0

        1/3

        6 May 2015, 11:31

        • Login

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