Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 2

Qt-interest Archive, March 2008
Give away focus?


Message 1 in thread

I'm using Qt 4.3.2.

Is there any way for my application to throw away focus?

I'm running automated tests, and ever time my app starts up again, it 
steals focus
from where I'm trying to get some work done. (If I could "reject" focus, 
I would
have a (say) command line option -testMode that would throw focus back 
to where
I'm trying to do work.)

I found KDE's "Focus Under Mouse" as opposed to "Focus Follows Mouse"
but "under mouse" has the unfortunate side effect of preventing me from 
getting
Google Calendar pop-ups.

If it's isn't possible to do this in Qt, does anyone know how to do it in X
(or KDE or Linux or whatever.)

--
 [ signature omitted ] 

Message 2 in thread

On Thursday 06 March 2008 23:20:12 Peter Hackett wrote:
> I'm using Qt 4.3.2.
>
> Is there any way for my application to throw away focus?

void QWidget::clearFocus ()?

-- 
 [ signature omitted ] 

Message 3 in thread

RE:
 > void QWidget::clearFocus ()?

This doesn't seem to do what I want. I want the "whole" application to
loose focus.

(I called clearFocus on my QMainWindow)

Any other thoughts on this?

Esben Mose Hansen wrote:
 > On Thursday 06 March 2008 23:20:12 Peter Hackett wrote:
 >
 > I'm using Qt 4.3.2.
 >
 > Is there any way for my application to throw away focus?
 >
 > > void QWidget::clearFocus ()?
 >
 > I'm running automated tests, and ever time my app starts up again, it
 > steals focusfrom where I'm trying to get some work done. (If I could 
"reject"
 > focus, I would have a (say) command line option -testMode that would 
throw
 > focus back to where I'm trying to do work.)
 >
 > I found KDE's "Focus Under Mouse" as opposed to "Focus Follows Mouse"
 > but "under mouse" has the unfortunate side effect of preventing me from
 > getting Google Calendar pop-ups.
 >
 > If it's isn't possible to do this in Qt, does anyone know how to do 
it in X
 > (or KDE or Linux or whatever.)
 >

--
 [ signature omitted ] 

Message 4 in thread

Peter Hackett wrote:
> 
> RE:
>  > void QWidget::clearFocus ()?
> 
> This doesn't seem to do what I want. I want the "whole" application to
> loose focus.
> 
> (I called clearFocus on my QMainWindow)
> 
> Any other thoughts on this?
> 
> Esben Mose Hansen wrote:
>  > On Thursday 06 March 2008 23:20:12 Peter Hackett wrote:
>  >
>  > I'm using Qt 4.3.2.
>  >
>  > Is there any way for my application to throw away focus?
>  >
>  > > void QWidget::clearFocus ()?
>  >
>  > I'm running automated tests, and ever time my app starts up again, it
>  > steals focusfrom where I'm trying to get some work done. (If I could 
> "reject"
>  > focus, I would have a (say) command line option -testMode that would 
> throw
>  > focus back to where I'm trying to do work.)
>  >
>  > I found KDE's "Focus Under Mouse" as opposed to "Focus Follows Mouse"
>  > but "under mouse" has the unfortunate side effect of preventing me from
>  > getting Google Calendar pop-ups.
>  >
>  > If it's isn't possible to do this in Qt, does anyone know how to do 
> it in X
>  > (or KDE or Linux or whatever.)

This is a window manager issue, not something specific to Qt. For the X 
window system you can try manipulating the XWMHints structure to set the 
input mode to no input for testing. See the Xlib Programming Manual, Vol 
1, Chapter 12
>  >
> 
> -- 
> To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx with 
> "unsubscribe" in the subject or the body.
> List archive and information: http://lists.trolltech.com/qt-interest/

--
 [ signature omitted ] 

Message 5 in thread

RE:
This is a window manager issue, not something specific to Qt. For the X 
window system you can try manipulating the XWMHints structure to set the 
input mode to no input for testing. See the Xlib Programming Manual, Vol 
1, Chapter 12

Thanks. I figured it might be outside of a "normal" Qt concern.

John McClurkin wrote:
> Peter Hackett wrote:
>>
>> RE:
>>  > void QWidget::clearFocus ()?
>>
>> This doesn't seem to do what I want. I want the "whole" application to
>> loose focus.
>>
>> (I called clearFocus on my QMainWindow)
>>
>> Any other thoughts on this?
>>
>> Esben Mose Hansen wrote:
>>  > On Thursday 06 March 2008 23:20:12 Peter Hackett wrote:
>>  >
>>  > I'm using Qt 4.3.2.
>>  >
>>  > Is there any way for my application to throw away focus?
>>  >
>>  > > void QWidget::clearFocus ()?
>>  >
>>  > I'm running automated tests, and ever time my app starts up again, it
>>  > steals focusfrom where I'm trying to get some work done. (If I 
>> could "reject"
>>  > focus, I would have a (say) command line option -testMode that 
>> would throw
>>  > focus back to where I'm trying to do work.)
>>  >
>>  > I found KDE's "Focus Under Mouse" as opposed to "Focus Follows Mouse"
>>  > but "under mouse" has the unfortunate side effect of preventing me 
>> from
>>  > getting Google Calendar pop-ups.
>>  >
>>  > If it's isn't possible to do this in Qt, does anyone know how to 
>> do it in X
>>  > (or KDE or Linux or whatever.)
>
> This is a window manager issue, not something specific to Qt. For the 
> X window system you can try manipulating the XWMHints structure to set 
> the input mode to no input for testing. See the Xlib Programming 
> Manual, Vol 1, Chapter 12
>>  >
>>
>> -- 
>> To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx 
>> with "unsubscribe" in the subject or the body.
>> List archive and information: http://lists.trolltech.com/qt-interest/
>
> -- 
> To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx with 
> "unsubscribe" in the subject or the body.
> List archive and information: http://lists.trolltech.com/qt-interest/
>

--
 [ signature omitted ] 

Message 6 in thread

According to my understanding There is only one Widget which may have
focus in the system.
So you need to move focus to other widget, which does not belong to your
application to lose it.
I am not sure why do you need to do this, but probably you can move it
to the desctop widget.
QT4 seems provides QDesktopWidget widget which should help you.
 
QDesktopWidget w;
int sc = primaryScreen ();
QWidget*p  = w.screen ( sc );

p->setFocus();

This is just an idea, code was not tested. 

Best regards;

Alex Malyushytsky
Research Engineer - Weidlinger Associates Inc.
office: 650 230 0210,
direct: 650 230 0349
web: http://www.wai.com



-----Original Message-----
From: Esben Mose Hansen [mailto:kde@xxxxxxxxxxxxx] 
Sent: Thursday, March 06, 2008 11:45 PM
To: qt-interest@xxxxxxxxxxxxx
Subject: Re: Give away focus?

On Thursday 06 March 2008 23:20:12 Peter Hackett wrote:
> I'm using Qt 4.3.2.
>
> Is there any way for my application to throw away focus?

void QWidget::clearFocus ()?

-- 
 [ signature omitted ] 

Message 7 in thread

Let me rewrite your idea.

Prog. A : main program
Prog. B : test program
Prog. A calls Prog. B. Then Prog. B give away focus.
Then Prog. A continue the job.

Is this correct?

Then, I think it is hard.
Prog. B's giving focus away never means Prog. A gets the focus again.

I think there are two scenario possible.

1. Change the structure so that Prog. B calls Prog. A.
2. Prog. A waits Prog. B to finish initializing jobs, then
   Let Prog. A grab the focus. (You may need inter-process communication) 

In similar situation with windows. I tried #2 scenario. It worked.
When I did that, Prog.A peeked the window messages to Prog. B.

Samuel Park

-----Original Message-----
From: Peter Hackett [mailto:peter@xxxxxxxxxxxx] 
Sent: Thursday, March 06, 2008 5:20 PM
To: QT Interest
Subject: Give away focus?

I'm using Qt 4.3.2.

Is there any way for my application to throw away focus?

I'm running automated tests, and ever time my app starts up again, it 
steals focus
from where I'm trying to get some work done. (If I could "reject" focus, 
I would
have a (say) command line option -testMode that would throw focus back 
to where
I'm trying to do work.)

I found KDE's "Focus Under Mouse" as opposed to "Focus Follows Mouse"
but "under mouse" has the unfortunate side effect of preventing me from 
getting
Google Calendar pop-ups.

If it's isn't possible to do this in Qt, does anyone know how to do it in X
(or KDE or Linux or whatever.)

--
 [ signature omitted ] 

Message 8 in thread

On Thursday 06 March 2008 3:20:12 pm Peter Hackett wrote:
> I'm using Qt 4.3.2.
>
> Is there any way for my application to throw away focus?
>
> I'm running automated tests, and ever time my app starts up again, it
> steals focus
> from where I'm trying to get some work done. (If I could "reject" focus,
> I would
> have a (say) command line option -testMode that would throw focus back
> to where
> I'm trying to do work.)
>
> I found KDE's "Focus Under Mouse" as opposed to "Focus Follows Mouse"
> but "under mouse" has the unfortunate side effect of preventing me from
> getting
> Google Calendar pop-ups.
>
> If it's isn't possible to do this in Qt, does anyone know how to do it in X
> (or KDE or Linux or whatever.)
>

I run my automated tests in Xvfb and/or Xnest.  With Xvfb, I never see the GUI 
show up, and I can even have the GUI tests run while I'm not logged into the 
machine.  Xnest is nice if you want to see many tests run, but not steal 
focus away from other apps, except the first time Xnest is started up.

Clint

--
 [ signature omitted ] 

Message 9 in thread

Hi!

clinton@xxxxxxxxxxxx schrieb:
> I run my automated tests in Xvfb and/or Xnest.  With Xvfb, I never see the GUI 
> show up, and I can even have the GUI tests run while I'm not logged into the 
> machine.  Xnest is nice if you want to see many tests run, but not steal 
> focus away from other apps, except the first time Xnest is started up.
>   

Another option is Xvnc. You also don't need a real display to run the 
tests (like Xvfb) but can connect to it with any VNC server from 
anywhere to see what is going on esp. if you need to look at any isseus.

In addition you could use Vmware or any other virtual machine which you 
can just minimize.

-- 
 [ signature omitted ] 

Message 10 in thread

Thanks. I tried to find a "null x server" with Google but obviously 
didn't find
the right terminology. Xvfb (X Virtual Frame Buffer) will certainly do 
the trick.

clinton@xxxxxxxxxxxx wrote:
> On Thursday 06 March 2008 3:20:12 pm Peter Hackett wrote:
>   
>> I'm using Qt 4.3.2.
>>
>> Is there any way for my application to throw away focus?
>>
>> I'm running automated tests, and ever time my app starts up again, it
>> steals focus
>> from where I'm trying to get some work done. (If I could "reject" focus,
>> I would
>> have a (say) command line option -testMode that would throw focus back
>> to where
>> I'm trying to do work.)
>>
>> I found KDE's "Focus Under Mouse" as opposed to "Focus Follows Mouse"
>> but "under mouse" has the unfortunate side effect of preventing me from
>> getting
>> Google Calendar pop-ups.
>>
>> If it's isn't possible to do this in Qt, does anyone know how to do it in X
>> (or KDE or Linux or whatever.)
>>
>>     
>
> I run my automated tests in Xvfb and/or Xnest.  With Xvfb, I never see the GUI 
> show up, and I can even have the GUI tests run while I'm not logged into the 
> machine.  Xnest is nice if you want to see many tests run, but not steal 
> focus away from other apps, except the first time Xnest is started up.
>
> Clint
>   

--
 [ signature omitted ]