Qt-interest Archive, April 2007
Disable QTreeView/QTreeWidget keyboard navigation
Message 1 in thread
Is there a way to disable QTreeView/QTreeWidget keyboard navigation?
I'm using a QTreeWidget to display a list of item summaries. I want to
make it where users can click on an item, but not be able to use the
arrow keys to navigate up/down the list. I'm not seeing any function to
display key presses.
The only thing I can think of is to create my own class that inherits
from QTreeWidget and reimplement QTreeWidget::keyPressEvent() and just
have it ignore all key press events.
Sean
--
[ signature omitted ]
Message 2 in thread
Murphy, Sean M. wrote:
> Is there a way to disable QTreeView/QTreeWidget keyboard navigation?
> I'm using a QTreeWidget to display a list of item summaries. I want to
> make it where users can click on an item, but not be able to use the
> arrow keys to navigate up/down the list. I'm not seeing any function to
> display key presses.
>
> The only thing I can think of is to create my own class that inherits
> from QTreeWidget and reimplement QTreeWidget::keyPressEvent() and just
> have it ignore all key press events.
Another thing I can think of is installing an event filter eating
the key events. Probably less code.
Andre'
--
[ signature omitted ]
Message 3 in thread
This looks perfect, in fact the example shown in the Qt docs shows them creating a "key press eater" event filter, so it looks like it's just a copy/paste job for me!
Thanks,
Sean
-----Original Message-----
From: André Pönitz [mailto:andre@xxxxxxx]
Sent: Tuesday, April 17, 2007 3:18 AM
To: Qt Interest List
Subject: RE: Disable QTreeView/QTreeWidget keyboard navigation
Murphy, Sean M. wrote:
> Is there a way to disable QTreeView/QTreeWidget keyboard navigation?
> I'm using a QTreeWidget to display a list of item summaries. I want to
> make it where users can click on an item, but not be able to use the
> arrow keys to navigate up/down the list. I'm not seeing any function
> to display key presses.
>
> The only thing I can think of is to create my own class that inherits
> from QTreeWidget and reimplement QTreeWidget::keyPressEvent() and just
> have it ignore all key press events.
Another thing I can think of is installing an event filter eating the key events. Probably less code.
Andre'
--
[ signature omitted ]
Message 4 in thread
you can overwrite the func QTreeView::moveCursor(CursorAction cursorAction, Qt::KeyboardModifiers modifiers) and do nothing in the func, so there would be no keyboard navigation Regards,Reimand
在2007-04-18,"Murphy Sean M." <sean.murphy@xxxxxxxxxx> 写道:
This looks perfect, in fact the example shown in the Qt docs shows them creating a "key press eater" event filter, so it looks like it's just a copy/paste job for me! Thanks, Sean -----Original Message----- From: André P?nitz [mailto:andre@xxxxxxx] Sent: Tuesday, April 17, 2007 3:18 AM To: Qt Interest List Subject: RE: Disable QTreeView/QTreeWidget keyboard navigation Murphy, Sean M. wrote: > Is there a way to disable QTreeView/QTreeWidget keyboard navigation? > I'm using a QTreeWidget to display a list of item summaries. I want to > make it where users can click on an item, but not be able to use the > arrow keys to navigate up/down the list. I'm not seeing any function > to display key presses. > > The only thing I can think of is to create my own class that inherits > from QTreeWidget and reimplement QTreeWidget::keyPressEvent() and just > have it ignore all key press events. Another thing I can think of is installing an event filter eating the key events. Probably less code. Andre' -- To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx with "unsubscribe" in the subject or the body. List archive and information: http://lists.trolltech.com/qt-interest/ -- To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx with "unsubscribe" in the subject or the body. List archive and information: http://lists.trolltech.com/qt-interest/
Message 5 in thread
On Monday, 16. April 2007 20:22, Murphy, Sean M. wrote:
> Is there a way to disable QTreeView/QTreeWidget keyboard navigation?
> I'm using a QTreeWidget to display a list of item summaries. I want to
> make it where users can click on an item, but not be able to use the
> arrow keys to navigate up/down the list. I'm not seeing any function to
> display key presses.
myTreeWidget->setFocusPolicy(Qt::NoFocus);
-Rainer
--
[ signature omitted ]
Message 6 in thread
Thanks! This works perfectly and seems like the simplest solution.
Sean
-----Original Message-----
From: Rainer Sabelka [mailto:sabelka@xxxxxxxxxxxxxxxx]
Sent: Wednesday, April 18, 2007 11:46 AM
To: qt-interest@xxxxxxxxxxxxx
Subject: Re: Disable QTreeView/QTreeWidget keyboard navigation
On Monday, 16. April 2007 20:22, Murphy, Sean M. wrote:
> Is there a way to disable QTreeView/QTreeWidget keyboard navigation?
> I'm using a QTreeWidget to display a list of item summaries. I want
> to make it where users can click on an item, but not be able to use
> the arrow keys to navigate up/down the list. I'm not seeing any
> function to display key presses.
myTreeWidget->setFocusPolicy(Qt::NoFocus);
-Rainer
--
[ signature omitted ]