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

  • Home
  • SEARCH
  • 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 3305954
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T21:13:52+00:00 2026-05-17T21:13:52+00:00

Hello all I have class that inherited from Qtreeview and I implement simple (

  • 0

Hello all
I have class that inherited from Qtreeview and I implement simple ( empty ) mousePressEvent function
But whenever I try to do this , the selection of the items in the Qtreeview are disabled , when I remove this function everything is working fine
What im missing here ?
Here Is the code:

void MyTreeWidget::mousePressEvent(QMouseEvent *event)
    {   
        QModelIndex index =  this->indexAt(event->pos());
        QAbstractItemModel *model = this->model();
        QMap<int, QVariant> ItemData = model->itemData(index);
        QMap<int, QVariant>::const_iterator i = ItemData.constBegin();
        while (i != ItemData.constEnd()) {
            QString k = QString::number(i.key());
            QString v = i.value().toString();

         ++i;
        }
        if (event->button() == Qt::LeftButton) {
             QByteArray itemData ;
             QString urlTo;
             itemData.append(urlTo);
             QDrag *drag = new QDrag(this);
             QMimeData *mimeData = new QMimeData;
             mimeData->setData("application/x-dnditemdata", itemData);
             drag->setMimeData(mimeData);

             Qt::DropAction dropAction = drag->exec(Qt::MoveAction);
             if (dropAction == Qt::MoveAction)
             {
                UT::getInstance()->LogToFile("dropAction");
             }


        }
        QTreeView::mousePressEvent(event);
    }
  • 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-05-17T21:13:53+00:00Added an answer on May 17, 2026 at 9:13 pm

    It’s because that when you override a method, the original on is not called anymore. You would have to manually call the mousePressEvent method of QTreeView in the method you created.

    Here is how to do it:

    void YourClass::mousePressEvent ( QMouseEvent * event )
    {
        QTreeView::mousePressEvent(event);
    }
    

    Hope this helps.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hello all and thanks for the attention! I have a problem that must both
$('div.box').html(hello) puts the word hello inside all my div's of class 'box'. They all
I have a python class/object as follows. class Hello: def __init__(self): self.x = None
Hello I'm a Django Beginner. I have a calendar that I want to be
I know this has been addressed before but I have service that returns a
Hello all you helpful folks @ stackoverflow! Best resources for Java GUI's? Looking at
NOTE: Using .NET 2.0, and VS2005 as IDE Hello all, I'm working on logging
All of my codes fail. They should print he, hello and 5 \n 3,
Hello I have the following error by git-fsck, which cannot be cleaned by git-gc
Hello again ladies and gents! OK, following on from my other question on ASP.NET

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.