3

I understand ( How does windowing work in qt embedded? ) that you should run one Application as the QWS Server to provide window management facilities, but that you can run other Apps with graphical interfaces as well in Qt Embedded for Linux.

I want to programmatically switch focus between windows without requiring mouse / keyboard interaction to achieve focus. I've searched the following docs but am not seeing any way to make a different window 'active':

http://qt-project.org/doc/qt-4.8/qwsserver.html
http://qt-project.org/doc/qt-4.8/qapplication.html
http://qt-project.org/doc/qt-4.8/qsessionmanager.html#details
http://qt-project.org/doc/qt-4.8/qwswindow.html

QWSServer has a method:

const QList<QWSWindow *> & QWSServer::clientWindows ()

Which returns a list of QWSWindows, but I don't see how I can make one of those windows the currently active window. How can I do this? Thanks -

Community
  • 1
  • 1
PhilBot
  • 748
  • 18
  • 85
  • 173

2 Answers2

2

The accepted answer is false in some sense. I think solution is to find needed window by clientWindows, then call QWSWindow::setActiveWindow() and then QWSWindow::raise().

QWSWindow provides the undocumented raise() method. See: qwindowsystem_qws.h definition of QWSWindow. You need this type of functionality if you want to make any sort of window manager.

Undocumented can beat impossible in some situations.

It is even more complex and difficult, if you wish to let non-Qt applications have focus, etc.

artless noise
  • 21,212
  • 6
  • 68
  • 105
Bikineev
  • 1,685
  • 15
  • 20
  • I never found a solution for this myself. Good luck - Please let me know here if your solution works. – PhilBot Jan 14 '14 at 16:39
  • there isn't such class in qt embedded – BЈовић Jan 31 '14 at 13:10
  • Yes, there is such a method as `QWSWindow::raise()`. I updated the answer to provide a link to the source. I have used this to do what the OP was asking. The only issue is whether you want to use *undocumented* features or not. However as **QWS** is deprecated in Qt5, I don't see why anyone wouldn't. The entire **QWS** is a dead infrastructure. – artless noise Apr 01 '14 at 15:47
1

If you are trying to do it using QWSServer::clientWindows (), then forget about it. QWSWindow and QWSClient are just providing interfaces to get information about client windows. You can not control them from the server application.

There are two ways to do what you want :

  • do it from the application creating the window
  • embed the client windows using QWSEmbedWidget, and then you get some kind of control
BЈовић
  • 62,405
  • 41
  • 173
  • 273