PDA

View Full Version : setWindowTitle() with nice font



Dwarf007
8th March 2006, 17:43
Does anyone know if there is a way to set the window title of an application with a font (for instance a *.ttf font ?)

I don't know how they did it on the tellico software, here:
http://www.periapsis.org/tellico/sshots/main_screen-1.0.png

Maybe it is not possible and the above screenshot is just a windowmanager style on the desktop of the person who did the screenshot..

wysota
8th March 2006, 18:04
It's a font set by KDE (it's window manager which controls decorations of a window). As an application developer you can't do anything about it.

high_flyer
10th March 2006, 20:25
I have a similar problem.
I would like to have my own window style regardless of the current window manager.
This MUST be possible, since it is possible under windows, it has to be possible under linux. (I am porting exactly such a dialog from windows at the moment)
So if any one knows a good link that offers inofrmation about customizing the title bar please share.
Thanks.

jacek
10th March 2006, 20:35
This MUST be possible, since it is possible under windows, it has to be possible under linux.
If it is possible under windows, it only means that it is possible under windows --- not every OS. Under X Windows, the title bar is controlled by window manager, not the application, so either you have to bypass the WM somehow or convince it to do what you want. KDE has some class for this, but I don't know if it will be enough.

high_flyer
10th March 2006, 20:41
well then, how does xmms do it?
Hmm... good idea, maybe I'll look in to that...;)

I just thought about it further...
I think the way to go is to disable the title bar, and grab the mouse in the part of the dialog designated for the custom title bar, use normal buttons to do the sysbutton stuff.
Easy said, don't know how easy it is to implement...

Oh, and I just read the QStyle docs...
The "right" way should be to implement a subclass of a QStyle, and draw your own title bar using QStyle::CC_TitleBar

wysota
12th March 2006, 14:26
well then, how does xmms do it?


Most likely it bypasses the window manager, like Jacek said.

high_flyer
13th March 2006, 19:12
I think the way to go is to disable the title bar, and grab the mouse in the part of the dialog designated for the custom title bar, use normal buttons to do the sysbutton stuff.
Easy said, don't know how easy it is to implement...
Just wanted to say that I just implemented this and its much easier then I thought, and it works just fine.
I will make a designer plugin out of it so I can use it in future such projects.
Just so you'll know this method works ok.

vitaly
13th March 2006, 20:43
I think your custom titlebar helps set the font you like. But some other problems will appear:

1. The configuration (position, color etc) of control buttons (minimize, close, maximise) will be different from button configuration of managed (by window manager) widgets. Also the color of titlebar will be different. It will not be good for some sort of applications.

2. Implementing your titlebar you notify window manager not to handle your widget (Qt::X11BypassWindowManagerHint). It means that you should write code for manading your widget (moving, raising, iconifying). Will your widget obtain the focus by the same way as other windows in the system? I think, no.

3. You should test whether your widget will appear in the window list? I'm not sure. I think, no!

4. May be, some users dislike your font.

XMMS has its own titlebar but you can see the widget name in the widget list. I think, that you shouldn't write your custom titlebar without absolute necessity.

high_flyer
13th March 2006, 21:39
I think your custom titlebar helps set the font you like. But some other problems will appear:
My motivation for the custom title bar is not the fonts, but the general look (style).
But my title bar allows any font or pixamap as a title.

1. The configuration (position, color etc) of control buttons (minimize, close, maximise) will be different from button configuration of managed (by window manager) widgets. Also the color of titlebar will be different. It will not be good for some sort of applications.

That is why I don't use normal push button, but a custom widget I made which is a styled button, which allows the user to "skin" it as he/she likes, in addition the button has the ability to have any amount of states and a pixmap to each state (i.e mouseover, pressed etc).
My styled button offers all the nessery "look" customization you make it fit to the users wishes.
This point of yours is correct, but was dealt with.

3. You should test whether your widget will appear in the window list? I'm not sure. I think, no!

This is true, I will have to check this, thanks for the tip :)

4. May be, some users dislike your font.
As I said, the title bar plugin allows customizing its look and font as the user wants them.
The programmer using this plugin can then query the widnow manger and use the window manager colors and fonts, but for that he wont need this plugin.

I think, that you shouldn't write your custom titlebar without absolute necessity.
Hehe... do you think I would do such a think just for fun?
Hmm... I might...:) but this is not the case..

Besides, as I said in my previous post, the REALY right way to do this, would be to derive QStyle (I used that aproach on the styled buttons), but it is much harder than the above implementation.
Thanks for the input!

high_flyer
17th March 2006, 20:02
3. You should test whether your widget will appear in the window list? I'm not sure. I think, no!

Ok I tested it, and at least under KDE there is an instance in the task bar (normaly like any other window)

Dwarf007
17th March 2006, 20:12
Just wanted to say that I just implemented this and its much easier then I thought, and it works just fine.
I will make a designer plugin out of it so I can use it in future such projects.
Just so you'll know this method works ok.

hey ! ;)

Will you share the source of your plugin ?

high_flyer
17th March 2006, 20:29
Sorry mate, this project is propreity code, and my boss would not take it well to find out that the time he paid to develop this is now freely available...
Also, I am using a custom styled button plugin (for the system buttons) which is quite a lot of code...
But I can help you to do it your self.
It really is not that hard.
All you need is a QLabel a spacer and 3 buttons, put them in a layout and there you have it.
In your QLabel you can show what ever you want any way you want it as a title.
Then you put this custom widget on a dialog, create the dialog with out a titlebar.
In your title bar you catch the mouse events calculate the movement and use that to move your dialog.
If you have more questions feel free to ask.

Hope this helps.

EDIT: I'll try to talk to my boss to allow me to release the code.
But that wont be before next week.

Dwarf007
17th March 2006, 20:35
Sorry mate, this project is propreity code, and my boss would not take it well to find out that the time he paid to develop this is now freely available...

No problem ! I fully understand ;)

I just asked because at the same time I would have had an interesting qtdesigner plugin example of something which I was wondering about (I was the initiator of this thread).

About the plugin, it also would have been interesting because I made a reimplementation of a QLineEdit and a QSpinBox recently and I was wondering how easy it was to do a plugin for QtDesigner out of those and if then it was possible to have some more/defined parameters which could be changed in the qt designer properties toolbox of the widget !
Well... but this is an other question. It would just have been a nice start as I never tried to do a qtdesigner plugin..

high_flyer
17th March 2006, 20:46
I was wondering how easy it was to do a plugin for QtDesigner out of those
This is easy.
You can use the clock custom plugin example as a base to work on for the plugin class it self.
If you have already a custom widget that you want to make available as a designer plugin, then its few minutes work.

vitaly
18th March 2006, 15:57
I'm using fvwm2. I tried to create borderless dialog with use of Qt3. I think that there is no difference of this feature implementation between Qt3 and Qt4.

1. This dialog was not appeared in the window list which is activated by ALT+TAB.
2. I have virtual screen which is divided into switchable four areas. When I switch between these areas the dialog remains always visible. It behaves like if to apply 'Stick". Does this work properly when you switch between several desktops in the KDE?
3. I configured my focus so that the widget under mouse takes the focus. But my dialog doesn't follow this setting.

high_flyer
19th March 2006, 15:31
1. This dialog was not appeared in the window list which is activated by ALT+TAB.
As the docs say, some of the flag interpretation/implementation is up to the windowing system.

This enum type is used to specify various window-system properties for the widget. They are fairly unusual but necessary in a few cases. Some of these flags depend on whether the underlying window manager supports them. (See the toplevel example for an explanation and example of their use.)


2. I have virtual screen which is divided into switchable four areas. When I switch between these areas the dialog remains always visible. It behaves like if to apply 'Stick". Does this work properly when you switch between several desktops in the KDE?
I didn't check if there is an entry in alt+tab, but I guess there should be since there is an instance in the task abr, I will check and let you know.
Other then that it works just like any other dialog.