Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. winrt exception thrown in drag & drop program

winrt exception thrown in drag & drop program

Scheduled Pinned Locked Moved Unsolved General and Desktop
7 Posts 3 Posters 535 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • U Offline
    U Offline
    user4592357
    wrote on last edited by
    #1

    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();
    }
    
    1 Reply Last reply
    0
    • hskoglundH Offline
      hskoglundH Offline
      hskoglund
      wrote on last edited by
      #2

      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...

      1 Reply Last reply
      1
      • mrjjM Offline
        mrjjM Offline
        mrjj
        Lifetime Qt Champion
        wrote on last edited by
        #3

        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 ?

        U 1 Reply Last reply
        0
        • mrjjM mrjj

          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 ?

          U Offline
          U Offline
          user4592357
          wrote on last edited by
          #4

          @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).

          1 Reply Last reply
          0
          • hskoglundH Offline
            hskoglundH Offline
            hskoglund
            wrote on last edited by
            #5

            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

            U 1 Reply Last reply
            0
            • hskoglundH hskoglund

              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

              U Offline
              U Offline
              user4592357
              wrote on last edited by
              #6

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

              1 Reply Last reply
              0
              • hskoglundH Offline
                hskoglundH Offline
                hskoglund
                wrote on last edited by
                #7

                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?

                1 Reply Last reply
                0

                • Login

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • Users
                • Groups
                • Search
                • Get Qt Extensions
                • Unsolved