[GH-ISSUE #142] DropArea doesn't work on Windows #84

Open
opened 2026-05-05 11:03:57 -06:00 by gitea-mirror · 9 comments
Owner

Originally created by @vadi2 on GitHub (Jun 13, 2019).
Original GitHub issue: https://github.com/qmlnet/qmlnet/issues/142

DropArea doesn't accept any input when used in Windows under Qml.Net, it always shows the "blocked" icon.

The given Qml file will work fine in Qml.Net on Linux and in C++ on Linux, and also OK under C++ on Windows, but not in Qml.net on Windows:

import QtQuick 2.12
import QtQuick.Window 2.12

Window {
    visible: true
    width: 640
    height: 480
    title: qsTr("Hello World")

    DropArea {
        id: dropArea
        anchors.fill: parent
        onEntered: {
            console.log(`raw text: ${drag.text}`)
        }

        onDropped: if (drop.hasText && drop.text) {
                       if (drop.proposedAction == Qt.MoveAction || drop.proposedAction == Qt.CopyAction) {
                           console.log(`Load: ${drop.text}`)
                       }
                   }
    }
}

Attached are two sample projects to reproduce the problem:
cpp-dnd.zip
dotnet-dnd.zip

With Qml.Net:

Peek 2019-06-13 12-36

With C++:

Peek 2019-06-13 12-37

Originally created by @vadi2 on GitHub (Jun 13, 2019). Original GitHub issue: https://github.com/qmlnet/qmlnet/issues/142 [DropArea](https://doc.qt.io/qt-5/qml-qtquick-droparea.html) doesn't accept any input when used in Windows under Qml.Net, it always shows the "blocked" icon. The given Qml file will work fine in Qml.Net on Linux and in C++ on Linux, and also OK under C++ on Windows, but not in Qml.net on Windows: ```js import QtQuick 2.12 import QtQuick.Window 2.12 Window { visible: true width: 640 height: 480 title: qsTr("Hello World") DropArea { id: dropArea anchors.fill: parent onEntered: { console.log(`raw text: ${drag.text}`) } onDropped: if (drop.hasText && drop.text) { if (drop.proposedAction == Qt.MoveAction || drop.proposedAction == Qt.CopyAction) { console.log(`Load: ${drop.text}`) } } } } ``` Attached are two sample projects to reproduce the problem: [cpp-dnd.zip](https://github.com/qmlnet/qmlnet/files/3287801/cpp-dnd.zip) [dotnet-dnd.zip](https://github.com/qmlnet/qmlnet/files/3287805/dotnet-dnd.zip) With Qml.Net: ![Peek 2019-06-13 12-36](https://user-images.githubusercontent.com/110988/59462171-fa663c80-8dd7-11e9-89d9-f75093eae566.gif) With C++: ![Peek 2019-06-13 12-37](https://user-images.githubusercontent.com/110988/59462206-17027480-8dd8-11e9-8645-9816615e95ab.gif)
Author
Owner

@vadi2 commented on GitHub (Jul 18, 2019):

@pauldotknopf any ideas?

<!-- gh-comment-id:512706617 --> @vadi2 commented on GitHub (Jul 18, 2019): @pauldotknopf any ideas?
Author
Owner

@pauldotknopf commented on GitHub (Jul 18, 2019):

Have you tried ruling out QmlNet? Can you reproduce with a standard Qt/QML project, within Qt Creator?

<!-- gh-comment-id:512791391 --> @pauldotknopf commented on GitHub (Jul 18, 2019): Have you tried ruling out QmlNet? Can you reproduce with a standard Qt/QML project, within Qt Creator?
Author
Owner

@vadi2 commented on GitHub (Jul 18, 2019):

It works with a standard project - see attached standard project and a gif of it working.

<!-- gh-comment-id:512797251 --> @vadi2 commented on GitHub (Jul 18, 2019): It works with a standard project - see attached standard project and a gif of it working.
Author
Owner

@pauldotknopf commented on GitHub (Jul 18, 2019):

I suspect it might be because of the type of Windows application that is created in .NET Core 2.X (console only).

Maybe try .NET Core 3, and use the option to publish executable as non-console (forgot what they called it).

<!-- gh-comment-id:512806612 --> @pauldotknopf commented on GitHub (Jul 18, 2019): I suspect it might be because of the type of Windows application that is created in .NET Core 2.X (console only). Maybe try .NET Core 3, and use the option to publish executable as non-console (forgot what they called it).
Author
Owner

@MaxMommersteeg commented on GitHub (Jul 18, 2019):

You mean <OutputType>WinExe</OutputType>?

<!-- gh-comment-id:512816569 --> @MaxMommersteeg commented on GitHub (Jul 18, 2019): You mean `<OutputType>WinExe</OutputType>`?
Author
Owner

@vadi2 commented on GitHub (Jul 18, 2019):

It doesn't help - I already build my application as:

dotnet publish --configuration Release --self-contained --runtime win-x64 /p:PublishTrimmed=true /p:PublishReadyToRun=true /p:OutputType=WinExe /p:TargetFramework=netcoreapp3.0

See the release at https://github.com/health-validator/Hammer, can't drag and drop into it on Windows :(

<!-- gh-comment-id:512900195 --> @vadi2 commented on GitHub (Jul 18, 2019): It doesn't help - I already build my application as: > dotnet publish --configuration Release --self-contained --runtime win-x64 /p:PublishTrimmed=true /p:PublishReadyToRun=true /p:OutputType=WinExe /p:TargetFramework=netcoreapp3.0 See the release at https://github.com/health-validator/Hammer, can't drag and drop into it on Windows :(
Author
Owner

@pauldotknopf commented on GitHub (Jul 18, 2019):

Bummer. I'm not really sure what to make of this. There must be some flag that you can use to tell windows that this window supports dropping.

I wonder how PyQt handles this, since it has it's own main entry point as well.

What do you think about using the unmanaged setup? https://qmlnet.github.io/setup/unmanaged-hosting/

It will likely fix it.

<!-- gh-comment-id:512913827 --> @pauldotknopf commented on GitHub (Jul 18, 2019): Bummer. I'm not really sure what to make of this. There must be some flag that you can use to tell windows that this window supports dropping. I wonder how PyQt handles this, since it has it's own main entry point as well. What do you think about using the unmanaged setup? https://qmlnet.github.io/setup/unmanaged-hosting/ It will likely fix it.
Author
Owner

@vadi2 commented on GitHub (Jul 20, 2019):

I'll see if it fixes things... but unmanaged doesn't make much sense to me: if I'm getting down to C++, I might as well use it for the entirety of the project. This is why I started out with managed.

<!-- gh-comment-id:513475017 --> @vadi2 commented on GitHub (Jul 20, 2019): I'll see if it fixes things... but unmanaged doesn't make much sense to me: if I'm getting down to C++, I might as well use it for the entirety of the project. This is why I started out with managed.
Author
Owner

@pauldotknopf commented on GitHub (Jul 20, 2019):

What I would do is jump into Qt to find how it is accepting the file-dropping on Windows, then investigate it to determine why it wouldn't be available in a console application.

<!-- gh-comment-id:513477948 --> @pauldotknopf commented on GitHub (Jul 20, 2019): What I would do is jump into Qt to find how it is accepting the file-dropping on Windows, then investigate it to determine why it wouldn't be available in a console application.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: github-starred/qmlnet#84
No description provided.