Hi, I'm having a problem capturing an event with a QListWidget. To be more specific what I'm trying to do is not allow a drag&drop from one QListWidget to another if that item (QString value) already exists. In the code below I've commented out the actual 'removal' of duplicates code, and just put a simple display mechanism to show when an event is captured.

I have set the eventfilter in the constructor of the class to enabled:

It seems though that the events are not being captured, ie my lineEdit is not being changed. I have tried different values for QEvent::xxxxx, and it has triggered events, but it was always sporadic, one time it would capture the event, the next drag it wouldn't capture???

Not sure where I've gone wrong here, or if there is a better way of handling this.

Qt Code:
  1. bool cecBrowse::eventFilter(QObject *target, QEvent *event)
  2. {
  3. if (target == ui->lbSearchResults) {
  4. if (event->type() == QEvent::DragMove) {
  5. //displayString( "event" );
  6. //QListWidget *listWidge = static_cast<QListWidget *>(target);
  7. //removeDuplicates(listWidge);
  8. ui->leTitleSearch->setText(ui->leTitleSearch->text() + ">");
  9. //event->setAccepted(false);
  10. event->ignore();
  11. return true;
  12. } else
  13. return false;
  14. }
  15. return QWidget::eventFilter(target, event);
  16. }
To copy to clipboard, switch view to plain text mode