Hi.

Previously I put this message in the forum for newbies, but no such luck. So I have decided to change it to this forum. Sorry for the inconvenience.

I'm trying to create a class that allows me to drag & drop items from a QComboBox.

Qt Code:
  1. class IndicatorComboBox : public QComboBox
  2. {
  3. Q_OBJECT
  4.  
  5. protected:
  6. QPoint m_dragStartPosition;
  7.  
  8. void mousePressEvent(QMouseEvent *pEvent);
  9. void mouseMoveEvent(QMouseEvent *pEvent);
  10.  
  11. public:
  12. IndicatorComboBox(QWidget *parent = 0);
  13.  
  14. signals:
  15.  
  16. public slots:
  17.  
  18. }
To copy to clipboard, switch view to plain text mode 

Qt Code:
  1. IndicatorComboBox::IndicatorComboBox(QWidget *parent) : QComboBox(parent)
  2. {
  3. }
  4.  
  5. void IndicatorComboBox::mousePressEvent(QMouseEvent *pEvent)
  6. {
  7. if (pEvent->button() == Qt::LeftButton) {
  8. m_dragStartPosition = pEvent->pos();
  9. }
  10.  
  11. QComboBox::mousePressEvent(pEvent);
  12. }
  13.  
  14. void IndicatorComboBox::mouseMoveEvent(QMouseEvent *pEvent)
  15. {
  16. if (!(pEvent->buttons() & Qt::LeftButton)) {
  17. return;
  18. }
  19.  
  20. if (currentIndex() < 0) {
  21. return;
  22. }
  23.  
  24. if ((pEvent->pos() - m_dragStartPosition).manhattanLength() < QApplication::startDragDistance()) {
  25. return;
  26. }
  27.  
  28. QDrag *drag = new QDrag(this);
  29. QMimeData *mimeData = new QMimeData;
  30.  
  31. mimeData->setText(currentText());
  32. drag->setMimeData(mimeData);
  33.  
  34. //drag->start();
  35. Qt::DropAction dropAction = drag->exec(Qt::CopyAction | Qt::MoveAction);
  36. }
To copy to clipboard, switch view to plain text mode 

My problem is that if there is the line "QComboBox::mousePressEvent(pEvent); " I can't drag the items. And, if I remove the line, the combobox will not open (but the drag works fine).

Thanks in advance.