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 outside the Main Window
Forum Updated to NodeBB v4.3 + New Features

Drag and Drop outside the Main Window

Scheduled Pinned Locked Moved General and Desktop
1 Posts 1 Posters 2.1k Views 1 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.
  • W Offline
    W Offline
    Woola20
    wrote on last edited by
    #1

    Hi, I have a question about the drag and drop.

    I created a custom widget that inherits from QWidget. This custom widget can be located in 2 different places. Initially, the custom widget is located in a QTabWidget (in fact a class that inherits from QTabWidget). This QTabWidget is located into a QDockedWidget in QMainWindow.

    I want to be able to drag the tab containing the custom widget, and create a top level window. So, when the main window will be minimized, my custom widget will not. Finally, I want to be able to put back the top level window in the QTabWidget.

    So far, I have created a class (CustomTabBar) that inherits from QTabBar, in order to be able to drag the custom widget from the QTabWidget to the outside (I'm using Qt 4.4.3 in CentOS 4). I reimplemented the mousePressEvent and mouseMoveEvent functions. In the mouseMoveEvent function, if the moving distance is long enough, I created a QDrag object.

    First problem : I cannot drop outside QMainWindow. Is there a way to do this? Should I use a particular mime data?

    So, now, I'm not able to drop outside QMainWindow, but I can inside it, since I added some code to be able to do it and accept drops. My custom widget is now independant from QMainWindow (I have set his parent to NULL), and I can minimize QMainWindow without affecting my custom widget.

    Now, I want to put back my custom widget into the QTabWidget. So I have reimplemented dragEnterEvent and dropEvent functions in my CustomTabBar and in the QTabWidget, and set them to accept drops. But when I begin the drag, my cursor doesn't change to tell me a drag has begins, and thus the QTabWidget does not accept the drop. So I tried to initialize the drag from my custom widget, ie detect the mouse press and move events, but these are not even called.

    Second problem: How do I initialize the drag from my custom widget (now a top level window)?

    Thanks

    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