[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-devel
Subject: Re: Adding KActionCollection to a window
From: Hamish Rodda <rodda () kde ! org>
Date: 2007-02-06 10:29:22
Message-ID: 200702062129.28383.rodda () kde ! org
[Download RAW message or body]
[Attachment #2 (multipart/signed)]
On Monday 29 January 2007 05:39, David Jarvie wrote:
> In KDE 4 code, I can't get actions to apply to a whole dialog window - they
> only happen after clicking on a particular widget within the window.
>
> The dialog is subclassed from KDialog. Its constructor contains the
> following relevant code:
>
> KActionCollection* actions = new KActionCollection(this);
> actions->setAssociatedWidget(topLevelWidget());
> actions->addAssociatedWidget(mListView);
> KStandardAction::selectAll(mListView, SLOT(selectAll()), actions);
> KStandardAction::deselect(mListView, SLOT(clearSelection()),
> actions);
>
> where mListView is a QTreeView widget contained within the dialog widget.
>
> When I click inside the QTreeView, the standard shortcuts ctrl-A and
> shift-ctrl-A work to (de)select view items. But the shortcuts don't work
> when the KDialog widget has focus without first clicking in the view. How
> can I get the shortcuts to apply to the window as a whole?
Use KActionCollection::setDefaultShortcutContext(Qt::WindowShortcut) and just
use the setAssociatedWidget(topLevelWidget()) line, don't worry about
addAssociatedWidget.
BTW, I believe there is an open issue with Qt about inheritance of
Qt::WidgetShortcut shortcuts in child widgets.
HTH,
Hamish.
[Attachment #5 (application/pgp-signature)]
>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic