Qt6 topics merged with General

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
    	MainWindow() noexcept;
    	void dragEnterEvent(QDragEnterEvent *event) override;
    	void dropEvent(QDropEvent *event) override;
    	bool readFile(const QString &fileName);
    	QTextEdit *m_pTextEdit = nullptr;
    #include "MainWindow.h"
    #include <QTextEdit>
    #include <QDragEnterEvent>
    #include <QMimeData>
    #include <QDebug>
    MainWindow::MainWindow() noexcept
    	: m_pTextEdit(new QTextEdit)
    	setWindowTitle("Text Editor");
    void MainWindow::dragEnterEvent(QDragEnterEvent *event)
    	if (event->mimeData()->hasFormat("text/uri-list"))
    void MainWindow::dropEvent(QDropEvent *event)
    	QList<QUrl> urls = event->mimeData()->urls();
    	if (urls.isEmpty())
    	QString fileName = urls.first().toLocalFile();
    	if (fileName.isEmpty())
    	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;
    	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...

  • Lifetime Qt Champion

    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.

    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)
    Screenshot 2020-05-31 at 20.43.02.png

  • @hskoglund
    it was long ago. but i didn't know what uwp is, so i guess i have chosen the green one.

  • Hmm, I think the exception (Exception thrown at 0x000...) you got is not possible to get with the green version, only with the red (UWP) version. Perhaps you can try reinstalling the green one?

Log in to reply