tags:

views:

1687

answers:

7

Hello, i have a QMainWindow. It has this parameters:

this->setWindowFlags(Qt::Tool);
this->setFocusPolicy(Qt::StrongFocus);
this->setAttribute(Qt::WA_QuitOnClose,true);

After showEvent calles my window is shown but unactivated. I tried to overload show function:

...    
QMainWindow::showEvent(event);
this->activateWindow();
...

But it doesn't help me.

EDIT: When i commented line

this->setWindowFlags(Qt::Tool);

everything worked fine, but i need in tool-flag. Any ideas?

EDIT:

  • OS: Linux
  • Programming language: c++
  • Qt version: 4.5.1
+1  A: 

Which operating system? Which Qt4?

On Linux you are doomed, the window manager can ignore what you are telling him. Keep it under consideration.

elcuco
Added information to post.
Ockonal
A: 

Does the same thing happen if you just make it a regular QWidget instead of a QMainWindow?

Also, perhaps you might be better trying to achieve whatever effect you need Qt::Tool for by other means if that's possible?

Troubadour
+1  A: 

Try to use QApplication::setActiveWindow()

e.tadeu
+1  A: 

The original apple Human Interface Guidelines(*) said that toolbox windows were "always on top but never activated". It also advises against using text boxes on them, precisely because the lack of activation-state feedback.

Check how other 'toolbox heavy' apps behave. I faintly recall that at least GIMP and InkScape seem very different in this aspect.

As elcuco said, the window manager can do whatever it wants with Qt's flags. Also, it sure would be different under KDE, Gnome, fluxbox, whatever.

(*):great document! somewhat outdated; but tool windows were already used and considered

Javier
A: 

Regarding Qt::Tool WindowFlags To quote Qt documentation

Indicates that the widget is a tool window. A tool window is often a small window with a smaller than usual title bar and decoration, typically used for collections of tool buttons. It there is a parent, the tool window will always be kept on top of it. If there isn't a parent, you may consider using Qt::WindowStaysOnTopHint as well. If the window system supports it, a tool window can be decorated with a somewhat lighter frame. It can also be combined with Qt::FramelessWindowHint

It seems the flags is a problem and using Qt::WindowStaysOnTopHint should solve your problem.

rocknroll
+3  A: 
stephan
A: 

just call show() after setWindowFlags().