i sad. your own editor. i mean subclass from QLineEdit and reimplement event filter, then send editingFinished(); signal only when your data is valid.
and for future, read more Qt's documentation. and examples, like this.
i sad. your own editor. i mean subclass from QLineEdit and reimplement event filter, then send editingFinished(); signal only when your data is valid.
and for future, read more Qt's documentation. and examples, like this.
Even if I create a widget, I still have the problem with losing focus. Creating a new widget doesn't solve the problem, it only makes my problem with delegates a problem with widgets.
The problem isn't with not sending the edtingFinished() signal -- I have a version of my code which doesn't even use that signal, and uses an event filter on the widget to detect when the user is done editing (presses 'enter' or 'esc', or the widget loses focus) -- it's with getting my widget to retain focus, and at having the FocusOut events fire when the window is closing, causing my "invalid data" error box to pop up a bunch.
Also, I think your link should be to hereYou should always check that you're using the latest version of the Qt docs. As you can see, that example has been updated to use the QStyledItemDelegate now.
Last edited by MattT; 31st July 2010 at 00:33.
QLineEdit automatically sends this signal, read.I have a version of my code which doesn't
Yes, but it isn't hooked up to anything by default. The signals that cause the editor to close are commitData and closeEditor, emitted by the delegate. Check the code for QListView/QAbstractItemView, you'll see. I have one version of my code where I hook that signal into one of my delegate's slots in order to validate the data and then, if valid, emit commitData and closeEditor to the ListView and, if not valid, open up an error dialog. The other version of my code doesn't listen for editingFinished, and just uses the QLineEdit's event filter to try to determine when the user has pressed enter, esc or the editor has lost focus. If it does it emits commitData and closeEditor.
and do not close editor inside cell?if not valid, open up an error dialog
you say you have 2 versions. both are not working?
Yup, now we're on the same page.
The problem isn't with the editor closing -- I can prevent that fine. The problem is with the editor losing focus. How do I keep focus on the editor, even when the user clicks on another widget?
Bookmarks