[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-devel
Subject: Re: Widget Focus
From: Milian Wolff <mail () milianw ! de>
Date: 2011-06-22 14:16:18
Message-ID: 201106221616.18899.mail () milianw ! de
[Download RAW message or body]
[Attachment #2 (multipart/signed)]
On Wednesday 22 June 2011 09:29:59 Kevin Funk wrote:
> Wednesday 22 June 2011, Steven Sroka <sroka.steven@gmail.com>:
> > Is there any way to set focus to manually a widget when a window opens? I
> > used QRadioButton::setFocus(Qt::ActiveWindowFocusReason), but it doesn't
> > help, the first widget placed on the window always has focus.
>
> Hey,
>
> Do you call setFocus *after* creating/layouting the widgets? Constructing
> other widgets afterwards will change the keyboard focus, so be sure to make
> this call last.
>
> Other than, it might help to use the event loop for calling the setFocus()
> slot on a widget, e.g.:
> QTimer::singleShot(0, widget, SLOT(setFocus()));
Note: Afair QMetaObject::invokeMethod is the preferred best-practice method to
do this, as it does not require timer.
bye
--
Milian Wolff
mail@milianw.de
http://milianw.de
["signature.asc" (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