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. Drag and drop bug in Linux?

Drag and drop bug in Linux?

Scheduled Pinned Locked Moved Unsolved General and Desktop
9 Posts 2 Posters 822 Views 2 Watching
  • 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.
  • H Offline
    H Offline
    hbatalha
    wrote on last edited by
    #1

    I am using a Linux Mint 20.1 to test my app in a linux environment and for some reason the drag and drop for text is not working as the mimeData()->text() is always empty.

    This is the code used to enable the drag and drop.

    MainWindow::MainWindow(QWidget *parent)
        : QMainWindow(parent)
        , ui(new Ui::MainWindow)
    {
        ui->setupUi(this);
    
        this->setAcceptDrops(true);
    
    //...
    }
    
    void MainWindow::dragEnterEvent(QDragEnterEvent *event)
    {
        if(event->mimeData()->hasFormat("text/plain"))
        {
            event->acceptProposedAction();
        }
    }
    
    void MainWindow::dropEvent(QDropEvent *event)
    {
        if( ! isProcessingLink)
        {
            qDebug() << event->mimeData()->text(); // empty
            processLink(event->mimeData()->text());
        }
    
        event->acceptProposedAction();
    }
    

    On windows this works fine but in linux there's no text.

    I am using Qt 6.2.0

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Did you check the type of the mime data you are getting ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      H 1 Reply Last reply
      0
      • SGaistS SGaist

        Hi,

        Did you check the type of the mime data you are getting ?

        H Offline
        H Offline
        hbatalha
        wrote on last edited by
        #3

        @SGaist I checked if it has text and it returned true.

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          That wasn't my question. What are the types that have been registered in the mine data object ? There might be a difference there.

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          H 1 Reply Last reply
          0
          • SGaistS SGaist

            That wasn't my question. What are the types that have been registered in the mine data object ? There might be a difference there.

            H Offline
            H Offline
            hbatalha
            wrote on last edited by
            #5

            @SGaist I don't know how to verify that.

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              QMimeData::formats.

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              H 1 Reply Last reply
              0
              • SGaistS SGaist

                QMimeData::formats.

                H Offline
                H Offline
                hbatalha
                wrote on last edited by
                #7

                @SGaist This is what I get when I run

                qDebug() << event->mimeData()->formats();
                
                QList("text/plain", "_NETSCAPE_URL", "chromium/x-renderer-taint", "text/html", "text/uri-list")
                
                1 Reply Last reply
                0
                • SGaistS Offline
                  SGaistS Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  Did you check what QMimeData::data returns for each type ?

                  Interested in AI ? www.idiap.ch
                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                  H 1 Reply Last reply
                  0
                  • SGaistS SGaist

                    Did you check what QMimeData::data returns for each type ?

                    H Offline
                    H Offline
                    hbatalha
                    wrote on last edited by hbatalha
                    #9

                    @SGaist Sorry for the late reply

                    I did that and it returned everything ok for each type. So I did this:

                    processLink(event->mimeData()->data("text/plain"));
                    

                    And it is working great. I don't know why mimeData()->text() is returning empty, can it be a bug?

                    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