Results 1 to 16 of 16

Thread: setWindowTitle() with nice font

  1. #1
    Join Date
    Mar 2006
    Location
    somewhere between France & Germany
    Posts
    34
    Thanks
    1
    Thanked 3 Times in 3 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default setWindowTitle() with nice font

    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/ssh...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..
    • The Manual said the program required Win95 or better, so I installed Linux.
    • Newton was a pessimist.
    • no Risk! no FuN!

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: setWindowTitle() with nice font

    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.

  3. #3
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: setWindowTitle() with nice font

    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.

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: setWindowTitle() with nice font

    Quote Originally Posted by high_flyer
    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.

  5. #5
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: setWindowTitle() with nice font

    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
    Last edited by high_flyer; 10th March 2006 at 20:51.

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: setWindowTitle() with nice font

    Quote Originally Posted by high_flyer
    well then, how does xmms do it?
    Most likely it bypasses the window manager, like Jacek said.

  7. #7
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: setWindowTitle() with nice font

    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.

  8. #8
    Join Date
    Jan 2006
    Location
    Moscow, Russia
    Posts
    20
    Qt products
    Qt3
    Platforms
    Unix/X11 Windows

    Default Re: setWindowTitle() with nice font

    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.

  9. #9
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: setWindowTitle() with nice font

    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!

  10. #10
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: setWindowTitle() with nice font

    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)
    Last edited by high_flyer; 17th March 2006 at 20:04.

  11. #11
    Join Date
    Mar 2006
    Location
    somewhere between France & Germany
    Posts
    34
    Thanks
    1
    Thanked 3 Times in 3 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Red face Re: setWindowTitle() with nice font

    Quote Originally Posted by high_flyer
    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 ?
    • The Manual said the program required Win95 or better, so I installed Linux.
    • Newton was a pessimist.
    • no Risk! no FuN!

  12. #12
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: setWindowTitle() with nice font

    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.

  13. #13
    Join Date
    Mar 2006
    Location
    somewhere between France & Germany
    Posts
    34
    Thanks
    1
    Thanked 3 Times in 3 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Red face Re: setWindowTitle() with nice font

    Quote Originally Posted by high_flyer
    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..
    • The Manual said the program required Win95 or better, so I installed Linux.
    • Newton was a pessimist.
    • no Risk! no FuN!

  14. #14
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: setWindowTitle() with nice font

    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.

  15. #15
    Join Date
    Jan 2006
    Location
    Moscow, Russia
    Posts
    20
    Qt products
    Qt3
    Platforms
    Unix/X11 Windows

    Default Re: setWindowTitle() with nice font

    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.

  16. #16
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: setWindowTitle() with nice font

    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.

Similar Threads

  1. font can not be changed
    By ashishsaryar in forum Qt Programming
    Replies: 4
    Last Post: 28th May 2008, 15:32
  2. Automatic font selection
    By NTwoO in forum Qt for Embedded and Mobile
    Replies: 0
    Last Post: 27th April 2007, 12:40
  3. Font not Antialiasing
    By ChasW in forum Qt Programming
    Replies: 6
    Last Post: 21st January 2007, 18:12
  4. Qt renders wrong font
    By durbrak in forum Qt Programming
    Replies: 8
    Last Post: 2nd November 2006, 14:36
  5. Determine system font
    By niala in forum Qt Programming
    Replies: 2
    Last Post: 21st March 2006, 22:45

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.