Details
-
Bug
-
Resolution: Unresolved
-
P3: Somewhat important
-
None
-
5.14.2
-
None
-
Windows 10, MSVC 2017 64-bit, QT 15.14.2
Description
When set attribute Qt::WA_NativeWindow for widget, then widget can't get drop in fullscreen mode. Example:
#include <QApplication> #include <QMainWindow> #include <QWidget> #include <QTextEdit> #include <QHBoxLayout> #include <QCheckBox> #include <QDebug> class Widget : public QTextEdit { public: Widget(QWidget* parent = nullptr) : QTextEdit(parent) { setAcceptDrops(true); setAttribute(Qt::WA_NativeWindow); setAttribute(Qt::WA_AcceptTouchEvents); setAutoFillBackground(false); setUpdatesEnabled(true); setFocusPolicy(Qt::StrongFocus); setMouseTracking(true); setTabletTracking(true); } void turnOnFullscreen() { if (!windowState().testFlag(Qt::WindowFullScreen)) { setParent(nullptr); show(); showFullScreen(); activateWindow(); raise(); setFocus(); } } }; class MMainWindow : public QMainWindow { public: MMainWindow(QWidget* parent = nullptr) : QMainWindow(parent) { QHBoxLayout* layout = new QHBoxLayout(this); Widget* textEdit = new Widget(this); QCheckBox* checkBox = new QCheckBox("Fullscreen mode", this); QTextEdit* dragText = new QTextEdit("Text for drag and drop", this); dragText->setReadOnly(true); connect(checkBox, &QCheckBox::stateChanged, [=](int state){ if(state == Qt::Checked) { textEdit->turnOnFullscreen(); } }); layout->addWidget(textEdit); layout->addWidget(dragText); layout->addWidget(checkBox); QWidget* window = new QWidget(this); window->setLayout(layout); setCentralWidget(window); } }; int main(int argc, char *argv[]) { QApplication a(argc, argv); MMainWindow w; w.show(); return a.exec(); }