[Qt-interest] Focus on a hidden widget.

Pritam Ghanghas pritam_ghanghas at infosys.com
Fri Mar 11 07:04:43 CET 2011



On Thu, 2011-03-10 at 21:22 +0530, Atlant Schmidt wrote:
> Expanding on what Bo said...
> 
> Remember, the widget really has to be visible so its
> parent widgets all the way up the chain of parentage
> must also be showing when you attempt to set focus
> to that widget. Even though you called show() on
> that widget, it might still not be visible if a parent
> (grandparent, etc.) is still hidden.
> 
> Logically, this makes sense: you wouldn't want to have
> a bunch of widgets hanging around with "pending focus
> should they become visible"; it would create a lot of
> ambiguity about which widget would *REALLY GET* the focus
> if a bunch of them suddenly became visible. Instead, the
> rule is simple: you can only assign focus to a widget
> that is currently really truly being shown.
> 
>                        Atlant
> 
> 
I think the documentation here means that "the widget wont gain focus
untill it is shown". But if you have called setFocus() on a widget and
it become visible after that, it will get focus. Unless setFocus() has
been called on some other widget in the mean time.
But this doesn't work if focusProxy is set on hidden widget.
I didnt look at qt code though?

> -----Original Message-----
> From: qt-interest-bounces+aschmidt=dekaresearch.com at qt.nokia.com [mailto:qt-interest-bounces+aschmidt=dekaresearch.com at qt.nokia.com] On Behalf Of Bo Thorsen
> Sent: Thursday, March 10, 2011 01:17
> To: qt-interest at qt.nokia.com
> Subject: Re: [Qt-interest] Focus on a hidden widget.
> 
> Den 09-03-2011 16:57, Kahola.g skrev:
> > Hi
> >
> > I am facing a very peculiar problem. My widget is not getting focus.
> > When i create the widget i call following two functions on it
> > show()
> > setFocus()
> >
> > this kind of code used to work. But all of a sudden i am in a situation
> > where it doesnt seem to work. As I understand " if set focus is called
> > on a widget that is not shown yet, it will get focus as soon as it
> > becomes visible". Am i wrong here?
> 
> Did you forget to call setFocusPolicy on the widget, perhaps?
> 
> Another possibility is that you are calling setFocus too early. From the
> docs: "Be aware that if the widget is hidden, it will not accept focus
> until it is shown." You might have to wait for the widget to be shown
> before you can call setFocus.
> 
> Bo Thorsen,
> Fionia Software.
> 
> --
> 
> Expert Qt and C++ developer for hire
> Contact me if you need expert Qt help
> http://www.fioniasoftware.dk
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at qt.nokia.com
> http://lists.qt.nokia.com/mailman/listinfo/qt-interest
> 
> This e-mail and the information, including any attachments, it contains are intended to be a confidential communication only to the person or entity to whom it is addressed and may contain information that is privileged. If the reader of this message is not the intended recipient, you are hereby notified that any dissemination, distribution or copying of this communication is strictly prohibited. If you have received this communication in error, please immediately notify the sender and destroy the original message.
> 
> Thank you.
> 
> Please consider the environment before printing this email.
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at qt.nokia.com
> http://lists.qt.nokia.com/mailman/listinfo/qt-interest


**************** CAUTION - Disclaimer *****************
This e-mail contains PRIVILEGED AND CONFIDENTIAL INFORMATION intended solely 
for the use of the addressee(s). If you are not the intended recipient, please 
notify the sender by e-mail and delete the original message. Further, you are not 
to copy, disclose, or distribute this e-mail or its contents to any other person and 
any such actions are unlawful. This e-mail may contain viruses. Infosys has taken 
every reasonable precaution to minimize this risk, but is not liable for any damage 
you may sustain as a result of any virus in this e-mail. You should carry out your 
own virus checks before opening the e-mail or attachment. Infosys reserves the 
right to monitor and review the content of all messages sent to or from this e-mail 
address. Messages sent to or from this e-mail address may be stored on the 
Infosys e-mail system.
***INFOSYS******** End of Disclaimer ********INFOSYS***



More information about the Qt-interest-old mailing list