Results 1 to 3 of 3

Thread: mousePressEvent with QColumnView

  1. #1
    Join Date
    Jun 2012
    Posts
    25
    Thanks
    7
    Qt products
    Qt4
    Platforms
    MacOS X

    Question mousePressEvent with QColumnView

    I am noticing that QColumnView::mousePressEvent is never called after setting it's model. I'm assuming QColumnView creates child widgets for each column which prevent the parent (QColumnView) from receiving the events.

    The problem I'm facing is after overwriting QColumnView::contextMenuEvent, I noticed if the user left clicks an item in column 2, then right clicks an item in column 1, it displays the contextMenu for the selected index in column 2. Therefor I overwrote QColumnView::mousePressEvent in hopes to allow right click to select the correct index/item before creating a contextMenu and ran into this problem.

    Perhaps there is a better way to address this issue or someone could point me to the documentation that explains how QColumnView propagates itself.

    Thanks for reading.

  2. #2
    Join Date
    Jul 2008
    Location
    Germany
    Posts
    511
    Thanks
    11
    Thanked 76 Times in 74 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: mousePressEvent with QColumnView

    Hi, I also had some problems with events and item view widgets and found that the QWidget returned by viewport() seems to be the one that handles events, not the item view widget itself.

    Ginsengelf

  3. The following user says thank you to Ginsengelf for this useful post:

    BreakBad (13th August 2013)

  4. #3
    Join Date
    Jun 2012
    Posts
    25
    Thanks
    7
    Qt products
    Qt4
    Platforms
    MacOS X

    Default Re: mousePressEvent with QColumnView

    Thanks for that tip, that allowed me to make progress. I installed an event filter on the view and printed out all of the event types. However, I see no mouseEvents other than perhaps the ContextMenu event type. I went as far as to subclass my own viewport widget and overwrite the event method and mousePressEvent method with similar results. There is another player, perhaps the scrollarea? This is a wacky widget.

Similar Threads

  1. How do I set selection in QColumnView?
    By hazzmax in forum Qt Programming
    Replies: 1
    Last Post: 22nd February 2017, 13:04
  2. How to use QColumnView with QSqlTableModel
    By npascual in forum Qt Programming
    Replies: 2
    Last Post: 21st June 2013, 07:37
  3. custom QColumnView, some questions
    By Mystical Groovy in forum Qt Programming
    Replies: 1
    Last Post: 9th October 2009, 14:03
  4. QModelIndex.column() error in QColumnView?
    By tlustoch in forum Qt Programming
    Replies: 1
    Last Post: 28th December 2008, 20:45
  5. QDirModel and QColumnView question
    By yartov in forum Qt Programming
    Replies: 3
    Last Post: 11th April 2008, 21:56

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.