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. QEvent::Drop not called
Forum Updated to NodeBB v4.3 + New Features

QEvent::Drop not called

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 2 Posters 543 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.
  • J Offline
    J Offline
    jmoriarty
    wrote on last edited by
    #1

    Here is a sample code of what I a trying to do! When I run it QEvent::Drop is never called! I even tried using viewport() and writing a piece including dragMove but nothing works.

    setAcceptDrops is true for both MainWindow and ui->EditorMdiArea

    Help is much needed!

    Thank You

    bool MainWindow::eventFilter(QObject *pFilterObj, QEvent *event) {
        if((pFilterObj==ui->EditorMdiArea) && (event-type()==QEvent::Drag)) {
             QDragEnterEvent *devent = (QDragEnterEvent*)event;
             qDebug()<<"Here we are 1";
                devent->acceptProposedAction();
                devent->accept();
        }
        //if((pFilterObj==ui->EditorMdiArea) && (QVariant(event->type()).toString()=="61")) {
        //  QDragEnterEvent *devent = (QDragEnterEvent*)event;
        //   qDebug()<<"Here we are 2";
        //  devent->accept();
        //}
        qDebug()<<"pFilterObj is "<<pFilterObj;
        qDebug()<<"event type is "<<event->type();
        //ui->EditorMdiArea->viewport()->installEventFilter(this);
        //ui->EditorMdiArea->viewport()->setAcceptDrops(true);
    
        if((pFilterObj==ui->EditorMdiArea) && (Qevent->type()==QEvent::Drop)) {
            qDebug()<<" Inside pFilterObj is "<<pFilterObj;
        qDebug()<<"Inside event type is "<<event->type();
            QDropEvent *devent = (QDropEvent*)event;
              qDebug()<<"Finaly Destination Reached";
                }
            }
        }
        }
        return false;
    }
    
    1 Reply Last reply
    0
    • J Offline
      J Offline
      jmoriarty
      wrote on last edited by
      #4

      No! But I got the catch. I just added return true in the if block of QEvent::Drag and it worked like a charm! Thanks @SGaist

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

        Hi and welcome to devnet,

        How did you setup the event filter ?
        What are you trying to drop ?

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

        J 1 Reply Last reply
        1
        • SGaistS SGaist

          Hi and welcome to devnet,

          How did you setup the event filter ?
          What are you trying to drop ?

          J Offline
          J Offline
          jmoriarty
          wrote on last edited by
          #3

          @SGaist Hello! I am trying to drop a file in the ui->EditorMdiArea so as to open it o drop!
          For setting up the event filter I have done the following ui->EditorMdiArea->installEventFilter(this); ui->EditorMdiArea->setAcceptDrops(true); in the constructor of the MainWindow

          1 Reply Last reply
          0
          • J Offline
            J Offline
            jmoriarty
            wrote on last edited by
            #4

            No! But I got the catch. I just added return true in the if block of QEvent::Drag and it worked like a charm! Thanks @SGaist

            1 Reply Last reply
            1

            • Login

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