[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-devel
Subject:    Re: Widget Focus
From:       Kevin Funk <krf () gmx ! de>
Date:       2011-06-22 7:29:59
Message-ID: 201106220929.59510.krf () gmx ! de
[Download RAW message or body]

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()));

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 <<
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic