[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-23 9:34:15
Message-ID: 201106231134.15561.mail () milianw ! de
[Download RAW message or body]
[Attachment #2 (multipart/signed)]
Steven Sroka, 23.06.2011:
> >On 22 June 2011 03:29, Kevin Funk <krf@gmx.de> 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.
>
> Thank you everyone. I simply added QRadioButton::setFocus() at the end
> of the block of code.
>
> You would know this better than me, is
> QTimer::singleShot/QMetaObject::invokeMethod preferable in this
> scenario?
Uhm, as it seems to work without the eventloop, everything is fine?
> I don't think it is guaranteed that each line of code is run after the
> previous line is successfully completed, therefore I might need to
> ensure the program only calls QRadioButton::setFocus() after the
> widgets are created and placed.
That is not really true. Well, sure - if you call a function that creates a
thread or delegates work to the eventloop than you could argue that the
"previous line is *not* successfully completed". But this would be a corner
case and is generally not the case. Just assume that everything is done after
you called a function.
> Would the event loop help in this scenario? Then again it is probably
> overkill, but it is an interesting situation.
> > 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()));
> >
> > This ensures that the widget(s) is/are fully constructed before receiving
> > the focus activation.
> >
> > Hope this helps,
> >
> > Greets
> >
> > --
> > Kevin Funk
> >
> >> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to
> >> unsubscribe <<
--
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