When the QListWidgetItem exit editing which signal will be sent?



  • I make the Item in the QListWidget editable.

    @listWidget->item(i)->setFlags(listWidget->item(i)->flags () | Qt::ItemIsEditable);@

    and I want to close the listWidget when I stop editing the items.
    Which signal will be sent in that moment?


  • Moderators

    the item delegate of your item view is responsible for the editor widget.
    So you can use it to get notified whenever the editor widget closes:
    @
    QAbstractItemDelegate* delegate = listWidget->itemDelegate();
    connect( delegate, SIGNAL(closeEditor(QWidget *, QAbstractItemDelegate::EndEditHint)), this, SLOT(...) );
    @

    Or do you want to close the editor?
    This should also be already handled by the delegate on pressing ESC key (IIRC) and on focus out.



  • [quote author="raven-worx" date="1384327903"]the item delegate of your item view is responsible for the editor widget.
    So you can use it to get notified whenever the editor widget closes:
    @
    QAbstractItemDelegate* delegate = listWidget->itemDelegate();
    connect( delegate, SIGNAL(closeEditor(QWidget *, QAbstractItemDelegate::EndEditHint)), this, SLOT(...) );
    @

    Or do you want to close the editor?
    This should also be already handled by the delegate on pressing ESC key (IIRC) and on focus out.[/quote]

    Yes, I want to close the editor when focus out.
    If I select another cell in the QTableView the editor is cloesed.
    But when I click the blank area in the QTableView or I click other widgets in the QMainWindow the editor just lost the focus. It doesn't close.

    The SpinBox delegate works well it can be closed when focus out.


  • Moderators

    are you using a custom delegate?



  • [quote author="raven-worx" date="1384845442"]are you using a custom delegate?[/quote]
    Yes, I create two custom delegate: SpinBoxDelegate and ListWidgetDelegate.
    The ListWidgetDelegate's editor can't be closed when focus out.


  • Moderators

    and why don't you provide such important information beforehand?

    And which type of widget is your editor? Can it even have the focus and thus a focus out event?
    Did you reimplement the event filter in the delegate or do you just create the editor widget in there?



  • [quote author="raven-worx" date="1384847896"]and why don't you provide such important information beforehand?

    And which type of widget is your editor? Can it even have the focus and thus a focus out event?
    Did you reimplement the event filter in the delegate or do you just create the editor widget in there?[/quote]

    I'm so sorry, my English is poor. so I forgot to provide these information.
    OK, my question is :
    I create two delegates for the QTableView.
    SpinBoxDelegate's editor is QSpinbox,
    ListDelegate's editor is QListWidget.

    I set the editable flag for the QListWidget's items so I could change the value in the QListWidget editor.

    It works well. The only problem is that when the QListWidget editor is shown and I click the blank area in the QTableView or click other QWidgets in the QMainWindow , the QListwidget editor is still shown.
    it didn't close automatically.

    If I click other cell in the QTableView, this editor will close automatically.


  • Moderators

    [quote author="raven-worx" date="1384847896"]
    And which type of widget is your editor? Can it even have the focus and thus a focus out event?[/quote]

    Edit: just post the code of the delegate that isn't working...


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.