winrt exception thrown in drag & drop program
-
i have a simple drag & drop application on windows 10, with qt 5.12.0.
whenever i perform 'drop', i get the following in output:Exception thrown at 0x00007FF92677A308 (KernelBase.dll) in QtGuiApp.exe: 0x40080202: WinRT transform error (parameters: 0x0000000080040155, 0x0000000080004002, 0x000000000000001D, 0x0000003A144FF2E0).
why do i get this? how can i fix this?
here's the code example:
#pragma once #include <QMainWindow> class QTextEdit; class MainWindow : public QMainWindow { Q_OBJECT public: MainWindow() noexcept; protected: void dragEnterEvent(QDragEnterEvent *event) override; void dropEvent(QDropEvent *event) override; private: bool readFile(const QString &fileName); private: QTextEdit *m_pTextEdit = nullptr; };
#include "MainWindow.h" #include <QTextEdit> #include <QDragEnterEvent> #include <QMimeData> #include <QDebug> MainWindow::MainWindow() noexcept : m_pTextEdit(new QTextEdit) { m_pTextEdit->setAcceptDrops(false); setAcceptDrops(true); setWindowTitle("Text Editor"); setCentralWidget(m_pTextEdit); } void MainWindow::dragEnterEvent(QDragEnterEvent *event) { if (event->mimeData()->hasFormat("text/uri-list")) event->acceptProposedAction(); } void MainWindow::dropEvent(QDropEvent *event) { QList<QUrl> urls = event->mimeData()->urls(); if (urls.isEmpty()) return; QString fileName = urls.first().toLocalFile(); if (fileName.isEmpty()) return; if (readFile(fileName)) setWindowTitle(tr("%1 - %2").arg(fileName).arg(tr("Drag File"))); } bool MainWindow::readFile(const QString &fileName) { qDebug() << __FUNCTION__ << fileName; return true; }
#include <QApplication> #include "MainWindow.h" int main(int argc, char *argv[]) { QApplication app(argc, argv); MainWindow window; window.show(); return app.exec(); }
-
Hi, I compiled your program using MSVC 2017 64-bit and it worked fine on my Windows 10 without exceptions, i.e. I drag a file into the program window and the debug output arrives from MainWindow::readFile.
You compiled the program using Qt version 5.12 UWP x64 MSVC 2017? UWP/WinRt programs require more security settings, that's I think why the exception strikes. Perhaps you need to edit the manifest file or something like that...
-
Hi
I tried your code with 5.14.2 mingw and it just worked and show no warning.
Just dragged item from a desktop.Is this a WinRT app ?
-
Hi
I tried your code with 5.14.2 mingw and it just worked and show no warning.
Just dragged item from a desktop.Is this a WinRT app ?
@hskoglund
yes, qt is compiled with msvc2017 x64. i'm uisng vs2019 latest update.@mrjj
i built it with visual studio, it's a qt gui application (created from qt extension gui application template). -
Hi, when you install Qt, there are two different msvc2017 x64, did you choose the red one and or the green one? (se screen dump below)
@hskoglund
it was long ago. but i didn't know what uwp is, so i guess i have chosen the green one.