Hi everyone,

it seems as if drops are not being accepted by qmainwindows (or their child widgets), that have called showFullscreen() once.
Calling setAcceptDrops(true) after the showFullscreen() call does not help.
Other MainWindows do still accept the drops, which have been dragged from the misfunctioning MainWindow.

I tried to code a minimal example which shows the problem:

mainwindow.cpp:
Qt Code:
  1. #include "mainwindow.h"
  2.  
  3. #include <QDragEnterEvent>
  4. #include <QDropEvent>
  5. #include <QLabel>
  6. #include <QVBoxLayout>
  7. #include <QPushButton>
  8.  
  9. class DragDropWidget : public QWidget {
  10. public:
  11. DragDropWidget(const QString &text, QWidget *parent);
  12. void dragEnterEvent(QDragEnterEvent *event);
  13. void dropEvent(QDropEvent *event);
  14. void dragLeaveEvent(QDragLeaveEvent *);
  15. void mousePressEvent(QMouseEvent *event);
  16.  
  17. QLabel *label;
  18. };
  19.  
  20. MainWindow::MainWindow(QWidget *parent) :
  21. QMainWindow(parent)
  22. {
  23. QWidget *central = new QWidget(this);
  24. QVBoxLayout *l = new QVBoxLayout(central);
  25.  
  26. widget1 = new DragDropWidget("1", this);
  27. widget2 = new DragDropWidget("2", this);
  28.  
  29. l->addWidget(widget1);
  30. l->addWidget(widget2);
  31.  
  32. QPushButton *fullscreen = new QPushButton(this);
  33. connect(fullscreen, SIGNAL(clicked()), this, SLOT(onPushButtonClicked()));
  34. l->addWidget(fullscreen);
  35.  
  36. central->setLayout(l);
  37. setCentralWidget(central);
  38. }
  39.  
  40. void MainWindow::onPushButtonClicked()
  41. {
  42. if(isFullScreen()) {
  43. showNormal();
  44. widget1->setAcceptDrops(true);
  45. }
  46. else {
  47. showFullScreen();
  48. widget1->setAcceptDrops(true);
  49. }
  50. }
  51.  
  52. DragDropWidget::DragDropWidget(const QString &text, QWidget *parent) :
  53. QWidget(parent)
  54. {
  55. setStyleSheet("QWidget { border: 1px solid blue; }");
  56. QVBoxLayout *l = new QVBoxLayout(this);
  57. setLayout(l);
  58. label = new QLabel(text, this);
  59. l->addWidget(label);
  60. setAcceptDrops(true);
  61. }
  62.  
  63. void DragDropWidget::dragEnterEvent(QDragEnterEvent *event)
  64. {
  65. if(event->mimeData()->hasFormat("application/mimeType")) {
  66. setStyleSheet("QWidget { border: 1px solid red; }");
  67. event->acceptProposedAction();
  68. }
  69. }
  70.  
  71. void DragDropWidget::dropEvent(QDropEvent *event)
  72. {
  73. QByteArray encodedData = event->mimeData()->data("application/mimeType");
  74. QDataStream stream(&encodedData, QIODevice::ReadOnly);
  75. QString data;
  76. stream >> data;
  77. label->setText(data);
  78. event->accept();
  79. setStyleSheet("QWidget { border: 1px solid blue; }");
  80. }
  81.  
  82. void DragDropWidget::dragLeaveEvent(QDragLeaveEvent *)
  83. {
  84. setStyleSheet("QWidget { border: 1px solid blue; }");
  85. }
  86.  
  87. void DragDropWidget::mousePressEvent(QMouseEvent *)
  88. {
  89. QDrag *drag = new QDrag(this);
  90. QMimeData *mimeData = new QMimeData;
  91.  
  92. QByteArray encodedData;
  93. QDataStream stream(&encodedData, QIODevice::WriteOnly);
  94. stream << label->text();
  95.  
  96. mimeData->setData("application/mimeType", encodedData);
  97. drag->setMimeData(mimeData);
  98. drag->exec();
  99. }
To copy to clipboard, switch view to plain text mode 

mainwindow.h:
Qt Code:
  1. #ifndef MAINWINDOW_H
  2. #define MAINWINDOW_H
  3.  
  4. #include <QMainWindow>
  5.  
  6. class DragDropWidget;
  7.  
  8. class MainWindow : public QMainWindow
  9. {
  10. Q_OBJECT
  11.  
  12. public:
  13. explicit MainWindow(QWidget *parent = 0);
  14.  
  15. private slots:
  16. void onPushButtonClicked();
  17.  
  18. private:
  19. DragDropWidget *widget1;
  20. DragDropWidget *widget2;
  21. };
  22. #endif // MAINWINDOW_H
To copy to clipboard, switch view to plain text mode 

main.cpp
Qt Code:
  1. #include <QApplication>
  2. #include "mainwindow.h"
  3.  
  4. int main(int argc, char *argv[])
  5. {
  6. QApplication a(argc, argv);
  7. MainWindow w;
  8. w.show();
  9.  
  10. MainWindow w2;
  11. w2.show();
  12.  
  13. return a.exec();
  14. }
To copy to clipboard, switch view to plain text mode 


You can download the full project here: https://dl.dropbox.com/u/140012/drag...fullscreen.zip

Do I miss something here? I cant be the first person, who has this problem.

Thank you.