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. [self solved]Text lose highlight
Forum Updated to NodeBB v4.3 + New Features

[self solved]Text lose highlight

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 Posters 1.9k 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.
  • P Offline
    P Offline
    pmjz
    wrote on last edited by
    #1

    Hi guys,

    I customized my treeview that inherited from QTreeview. I wanna drag and drop work and reimplement mousepressevent,releaseevent and moveevent. everything works very well. but when I click on items in my treeview, text loses highlight. welcome any advices. thanks a lot

    1 Reply Last reply
    0
    • A Offline
      A Offline
      andre
      wrote on last edited by
      #2

      First advice: show relevant code.

      1 Reply Last reply
      0
      • P Offline
        P Offline
        pmjz
        wrote on last edited by
        #3

        my Code:

        @
        MyTreeView::MyTreeView(QWidget *parent) :
        QTreeView(parent)
        {
        }

        MyTreeView::~MyTreeView()
        {
        }

        void MyTreeView::mousePressEvent(QMouseEvent *event)
        {
        //to do my logic
        QTreeView::mousePressEvent(event);
        }

        void MyTreeView::mouseMoveEvent(QMouseEvent *event)
        {
        //to do my logic
        QTreeView::mouseMoveEvent(event);
        }

        void MyTreeView::mouseReleaseEvent(QMouseEvent *event)
        {
        //to do my logic
        QTreeView::mouseReleaseEvent(event);
        }
        @

        1 Reply Last reply
        0
        • P Offline
          P Offline
          pmjz
          wrote on last edited by
          #4

          this problem has been fixed,just add one line:

          @
          void MyTreeView::mouseReleaseEvent(QMouseEvent *event)
          {
          //to do my logic
          QTreeView::mouseReleaseEvent(event);
          QModelIndex currentIndex = this->indexAt(event->pos());
          if(currentIndex.isValid())
          {
          this->setCurrentIndex(currentIndex);
          }
          }
          @

          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