Results 1 to 3 of 3

Thread: QAbstractItemView::entered signal does not fire for QTreeView row when row has widget

  1. #1
    Join Date
    Feb 2019
    Posts
    2
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: QAbstractItemView::entered signal does not fire for QTreeView row when row has wi

    When I add a widget to a row in a QTreeView using setIndexWidget(), the QAbstractItemView::entered signal, used to detect when the mouse hovers over a row, does not fire unless the mouse is over the part of the row that the QWidget does not occupy.

    See picture below that shows 3 rows.

    hovermodel.PNG

    When the mouse enters the white space it works, but if it enters the green space (the QWidget) it does not. How do I fix this?

    This is how the QWidget is put in the row. The QWidget is necessary because I need a clickable button in each row

    Qt Code:
    1. CustomItem* item= new CustomItem(_uiDoc, *sketch);
    2. parent->appendRow(item);
    3. setIndexWidget(item->index(), item->GetWidget());
    To copy to clipboard, switch view to plain text mode 


    Added after 1 15 minutes:


    This was the soluton
    Qt Code:
    1. item->GetWidget()->setAttribute(Qt::WA_TransparentForMouseEvents);
    To copy to clipboard, switch view to plain text mode 
    Last edited by Dkrii; 7th February 2019 at 21:57.

  2. #2
    Join Date
    Feb 2019
    Posts
    2
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: QAbstractItemView::entered signal does not fire for QTreeView row when row has wi

    Quote Originally Posted by Dkrii View Post
    When I add a widget to a row in a QTreeView using setIndexWidget(), the QAbstractItemView::entered signal, used to detect when the mouse hovers over a row, does not fire unless the mouse is over the part of the row that the QWidget does not occupy.

    See picture below that shows 3 rows.

    hovermodel.PNG

    When the mouse enters the white space it works, but if it enters the green space (the QWidget) it does not. How do I fix this?

    This is how the QWidget is put in the row. The QWidget is necessary because I need a clickable button in each row

    Qt Code:
    1. CustomItem* item= new CustomItem(_uiDoc, *sketch);
    2. parent->appendRow(item);
    3. setIndexWidget(item->index(), item->GetWidget());
    To copy to clipboard, switch view to plain text mode 


    Added after 1 15 minutes:


    This was the soluton
    Qt Code:
    1. item->GetWidget()->setAttribute(Qt::WA_TransparentForMouseEvents);
    To copy to clipboard, switch view to plain text mode 

    nevermind, that made the widget then unusable.

  3. #3
    Join Date
    Jan 2006
    Location
    Bremen, Germany
    Posts
    554
    Thanked 86 Times in 81 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QAbstractItemView::entered signal does not fire for QTreeView row when row has wi

    Quote Originally Posted by Dkrii View Post
    nevermind, that made the widget then unusable.
    And that's the reason why the view does not get events - the widget needs it and doesn't pass it to the view. You have to do it on your own. E.g. by reimplementing QWidget::focusInEvent()

Similar Threads

  1. QSocketNorifier on stdin dont fire signal WinXP
    By dexli in forum Qt Programming
    Replies: 2
    Last Post: 11th December 2013, 11:38
  2. Signal is emtted, slot does not fire.
    By JasonKretzer in forum Newbie
    Replies: 3
    Last Post: 1st August 2013, 22:40
  3. QSqlTableModel OnFieldChange causes what signal to fire?
    By scott_hollen in forum Qt Programming
    Replies: 0
    Last Post: 27th September 2011, 21:23
  4. Replies: 2
    Last Post: 12th January 2011, 21:39
  5. Replies: 3
    Last Post: 26th November 2009, 19:28

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.