Capturing Key_up and Key_down for QTreeView
I've attempted to capture key press events by both overriding keyPressEvent and event, but I am only able to capture the right arrow and left arrow keys. Any examples would help. I searched the forum...but all examples don't seem to work for me.
Thanks in advance.
Re: Capturing Key_up and Key_down for QTreeView
Could we see some code? I don't have any problems catching Qt::Key_Up or Qt::Key_Down in keyPressEvent().
Re: Capturing Key_up and Key_down for QTreeView
Unfortunately my dev machine crashed the other day...so I no longer have that code. However, looking at the situation I'm wondering if I'm over-complicating the problem.
I want to call a function whenever a new row is selected within a QTreeView. Right now I have this QTreeView connected using both the "entered" and "pressed" signal. This works fine as long as the user clicks and selects a new row. However, if the user uses the up and down arrow keys to change rows, my function does not get called. Rather then capturing the up and down arrow keys, is there an easier way to capture this event?
Thanks in advance.
Re: Capturing Key_up and Key_down for QTreeView
Yeah, you can use QAbstractItemView::selectionModel() to retrieve the item selection model and connect to one of it's signals, like QItemSelectionModel::selectionChanged().
Re: Capturing Key_up and Key_down for QTreeView
Thanks JPN...I'll give that a shot!