Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-85775

Doesn't work Drag&Drop in fullscreen mode with Qt::WA_NativeWindow flag

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P3: Somewhat important
    • None
    • 5.14.2
    • None
    • Windows 10, MSVC 2017 64-bit, QT 15.14.2
    • Windows

    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();
      }
      
      

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            qt.team.quick.subscriptions Qt Quick and Widgets Team
            dimakoltun dimakoltun
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes