[SOLVED] Drag and Drop problems with custom build tab widget



  • I've inherited a codebase at work that includes a custom build tab widget which consists of:

    • A TabManager derived from a QObject
    • A QTabBar as a member of the TabManager
    • TabPageWidgets derived from QWidget

    There is also a mechanism by which tabs can be undocked from the TabManager, and there used to be a mechanism that allowed them to redocked, and I've been tasked with foguring out why it no longer works.

    The TabManager also contains a TabBarEventFilter object, another custom class solely for handling events on the QTabBar. Within this class is a function called eventFilter(QObject*, QEvent*), which has a section that handles DragMove and DragEnter events. I've checked the code out and confirmed that the QTabBar is being set to accept drag events by writing the following inside the eventFilter function

    @if ( ( eventType == QEvent::DragEnter ) || ( eventType == QEvent::DragMove ) ) {
    bool isEnter = ( eventType == QEvent::DragEnter );

      QDragMoveEvent* de = static_cast<QDragMoveEvent*>(event); // Returns true
      de->setAccepted( true );
      std::cout << "de->isAccepted(): " << de->isAccepted() << std::endl; // Returns true
    
      return true;
    

    }@

    Given that the acceptance of the drag event is being confirmed, I'm at a loss to explain why the tab is still not dockable. From what I've said above, can anyone think of any reason why this should be the case?



  • Did you implement the dropEvent()?



  • Also check if the MimeType is accepted when drop occurs.



  • Thanks a lot for your responses. It turns out the problem was that the MIME types weren't getting handled properly due to a couple of function stubs that had been forgotten about during a previous refactoring exercise.



  • So this is solved?



  • It is, and I've updated the title accordingly.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.