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 delegates, editors, and "chicken or egg" problem
Forum Updated to NodeBB v4.3 + New Features

Custom delegates, editors, and "chicken or egg" problem

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 2 Posters 427 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.
  • R Offline
    R Offline
    Robert Hairgrove
    wrote on last edited by Robert Hairgrove
    #1

    According to the documentation, when the editing is finished in a custom editor, there is a signal closeEditor() which should be emitted. I would like to change the optional argument QAbstractItemDelegate::EndEditHint from QAbstractItemDelegate::NoHint to QAbstractItemDelegate::EditNextItem. This means that my custom editor widget needs to emit that signal itself (somewhere).

    Setting up a delegate for editing an item in a table view, if it is something simple like a combo box, seems to work OK without anything special, but looking at the Spreadsheet Example, I would need to subclass QComboBox if I wanted to change the argument as stated above.

    So the question is this: Where to emit the signal?

    If a QLineEdit is used, as in the spreadsheet example, there is a custom function which is connected to the editingFinished signal which does this (as well as emitting the commitData signal). But one of my editors (on a field in a table view) is actually like a dialog which opens an editor containing another table view with its own model, etc. and some buttons (OK, Cancel, etc. although it is not a dialog, but inherits QFrame). So I can hook up the buttons' clicked signal to something like that. Would that be the standard procedure? Or should I emit the closeEditor and commitData signals somewhere else? (I assume that the frame's closeEvent would not be appropriate here ... i.e., this would be the "chicken or egg" part of the question. Emitting the closeEditor signal would eventually call close() on my editor, and only then would I receive the close event).

    1 Reply Last reply
    0
    • Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @Robert-Hairgrove said in Custom delegates, editors, and "chicken or egg" problem:

      QAbstractItemDelegate::EndEditHint from QAbstractItemDelegate::NoHint to QAbstractItemDelegate::EditNextItem.

      Why?
      It's not really possible, at least not when looking at the code where it is emitted. EditNextItem is only emitted when the TAB key is pressed.

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      R 1 Reply Last reply
      0
      • Christian EhrlicherC Christian Ehrlicher

        @Robert-Hairgrove said in Custom delegates, editors, and "chicken or egg" problem:

        QAbstractItemDelegate::EndEditHint from QAbstractItemDelegate::NoHint to QAbstractItemDelegate::EditNextItem.

        Why?
        It's not really possible, at least not when looking at the code where it is emitted. EditNextItem is only emitted when the TAB key is pressed.

        R Offline
        R Offline
        Robert Hairgrove
        wrote on last edited by
        #3

        @Christian-Ehrlicher Thank you, Christian ... in that case, for most of the delegates there is no need to emit this signal myself.

        However, I mentioned a custom dialog-like editor in my last paragraph. I will need to emit the signal here in any case, but I'm not sure which slot or event to use. If I have a slot connected to my "OK" button's clicked signal, would that be the most appropriate for emitting closeEditor?

        1 Reply Last reply
        0
        • R Offline
          R Offline
          Robert Hairgrove
          wrote on last edited by
          #4

          I think this is now solved ... I can follow the example of "Star Delegate" almost verbatim.

          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