Hey guys,

at first: thanks a lot for the good work, I fully support the step to build up a new site - looks awesome

I posted this message a few hours ago at qtforum.org, when i hadn't read what was going on. So i hope this cross-post is ok

I've got a strange problem with drag 'n drop in my app. It works if you drag the label for the first time, but afterwoods that "drag symbol"(little rect) just remains at the starting position, no matter where you move the mouse. The mouse cursor shows then that a drop isn't permitted (everywhere). The TemplateWidget then also doesn't get any dropevents anymore. I've got the same issue in another Dialog, but I use different Widgets there.

Here's my code (using QT4), i wrote it after after having a look at the QT-Examples. QDragLabel is the Widget where the drag begins, it should end in a QTemplateWidget.

Qt Code:
  1. void QDragLabel::mousePressEvent(QMouseEvent *event)
  2. {
  3. if (!(event->buttons() & Qt::LeftButton))
  4. return;
  5.  
  6. QDrag drag(this);
  7.  
  8. QMimeData *mimeData = new QMimeData;
  9.  
  10. mimeData->setText(m_text);
  11. drag.setMimeData(mimeData);
  12.  
  13. drag.start(Qt::CopyAction);
  14. event->accept();
  15. }
  16.  
  17. void QTemplateWidget::dragEnterEvent (QDragEnterEvent *event)
  18. {
  19. event->accept();
  20. }
  21.  
  22. void QTemplateWidget::dropEvent ( QDropEvent * event )
  23. {
  24. bool ok;
  25. QString text;
  26.  
  27. if(!event->mimeData()->hasText())
  28. {
  29. event->ignore();
  30. return;
  31. }
  32.  
  33. event->acceptProposedAction();
  34. if(event->mimeData()->text()=="Textfeld")
  35. {
  36. while(true)
  37. {
  38. text = QInputDialog::getText(this, "Bitte geben sie den Namen für das Textfeld an:",
  39. "Name:", QLineEdit::Normal,
  40. "", &ok);
  41. if (ok && !text.isEmpty())
  42. break;
  43. }
  44. QFontMetrics fontmetrics=QApplication::fontMetrics();
  45. QRect rect=fontmetrics.boundingRect(text);
  46. int x=event->pos().x()-rect.width()/2;
  47. int y=event->pos().y()-rect.height()/2;
  48. m_myLabelsX.append(x);
  49. m_myLabelsY.append(y);
  50.  
  51. m_myLabelsText.append(text);
  52. }
  53. update();
  54. }
To copy to clipboard, switch view to plain text mode 

Thanks in advance,
kiker99