Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8478999
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T18:54:14+00:00 2026-06-10T18:54:14+00:00

I have a Qt Desktop aplication which has several top-level widgets. Subwidgets of top-level

  • 0

I have a Qt Desktop aplication which has several top-level widgets. Subwidgets of top-level widgets can be moved between top-level widgets by using drag-and-drop mechanism.

The problem i have now is to drop a sub-widget outside any of existing top-level widgets and create a new top-level widget to contain this one. Lets call this separation.

Can this be done using drag-and-drop? I could not find a way where my dropEvent goes?
Can i want to handle the drop event in my application even if the drop place is not allowed? Maybe a mouse release or something?

I cannot change everything now but also a question for the future. Is docking/undocking a better way to do this?

Regards
Mihai

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T18:54:16+00:00Added an answer on June 10, 2026 at 6:54 pm

    I found a way to do this. When drag moves outside of the application widgets QDrag object emits a targetChanged signal with 0 parameter.

    So i inherited from QDrag and then emit a custom signal in destructor if the target() is null.

    The only problem is that the cursor looks like interdiction of drop and this i could not fix because QDrag can only set cursor pixmap for valid actions like Move or Copy or Link

    Update:

    Here is the inherited class.

    class TabDrag: public QDrag
    {
        Q_OBJECT
    public:
        explicit TabDrag(QWidget *dragSource);
        ~TabDrag();
    
    signals:
        void tearOff(); /// emit tearOff signal if the QDrag object is destroyed and target was null
    };
    
    TabDrag::TabDrag(QWidget *dragSource):QDrag(dragSource)
    {
    }
    
    TabDrag::~TabDrag()
    {
        // check if we need to detach this tab
        if(!target())
        {
            emit tearOff();
        }
    }
    

    The tearOff signal should be connected to whatever you want to happen. In my case i pull out the widget from the tab and change parent to a new window.

    Example of usage

    void MyTabBar::mouseMoveEvent(QMouseEvent* event)
    {
    ..................
        TabDrag * drag = new TabDrag(this);
        drag->setMimeData(mimeData);
        drag->setPixmap(*m_tabPixmap.data());
        drag->setHotSpot(QPoint(m_dragStartPos.x() - tabAtRect.x(), m_dragStartPos.y() - tabAtRect.y()));
        drag->exec();
    
        connect(drag, SIGNAL(tearOff()), this, SLOT(onTearOff()));
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Silverlight 4 desktop application which I control using a touchscreen (on
I have a desktop application which has to read an excel file (either .xls
We have a desktop application, which has been provided a web UI by hosting
I have a desktop-like application which has 2 controllers: 'Desktop' which represents desktop icons
We've developed a desktop application using .NetFX3.5 which has some winforms and two WPF
I have a DESKTOP application which interacts with a web service through their RESTful
I have one desktop application which was implemented in C#. This app uploads file
I have created a desktop application which continuously changes the image on a fixed
I have a custom desktop application which invokes an ASMX web service. The Service
I have a .NET 2005 (C#) desktop application, in which there is a login

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.