A few QToolBar Improvements

Published Friday July 17th, 2009
5 Comments on A few QToolBar Improvements
Posted in Qt, Styles, Styles/QGtkStyle, Uncategorized

Both GNOME and KDE has a nice little control panel that allows you to configure how you want your toolbars to appear. Pure Qt applications show only the icons by default. Unfortunately, I don’t think it is a good idea to suddenly change this behavior, but we can do the next best thing and allow you to opt-in. Starting with 4.6, you can use setToolButtonStyle(Qt::ToolButtonFollowStyle) on your mainwindow, tool bar or tool button to make your application dynamically follow desktop settings.

Here is a Qt app on GNOME with “Text below Items”:

below31.png

And this is how it looks with with “Text beside Items”:
beside3.png

There are a few things you should do before you enable this setting though. First you should allways set QAction::IconText, otherwise your annoyingly long tool tip text will suddenly appear next to your icon. However, as you can barely see in the second screenshot, doing that is not enough to properly support Qt::TextBesideIcon since putting all that text into the toolbar generally takes up a bit too much space.

To solve this problem we added QAction::setPriority(QAction::Priority). In other words, you can now mark actions as more or less important. Quite handy for dynamic layouts determining which items to collapse first. In this case,  actions with low priority will hide their label automatically when changing to this desktop setting.

Do you like this? Share it
Share on LinkedInGoogle+Share on FacebookTweet about this on Twitter

Posted in Qt, Styles, Styles/QGtkStyle, Uncategorized

5 comments

Linux says:

Great job!
It will make things easier to integrate Qt applications into GNOME.

What about customizable toolbar? It would be nice to be able to drag and drop a QAction onto the toolbar. With the animation framework you could animate the move of the neighboring icons to show where the icon will be positioned.

QtFan says:

Great !

chaz6 says:

It is a shame that this cannot be the default behaviour. Is there a list of these “quirks” kept somewhere that developers should be aware of?

Jens says:

@chaz6: Yeah, having a page dedicated to how you make applications truly integrate with the native platform is something I have been thinking about for a while. The information is somewhat scattered at the moment.
@Linux: There is already something available for this here: http://www.qtsoftware.com/products/appdev/add-on-products/catalog/4/Widgets/qttoolbardialog/ but unfortunately it’s not as fancy as the one you are suggesting.

Artem S. Tashkinov says:

I feel like I have to propose one more suggestion:

“Selective text next to icons”, and when creating a UI for your icon toolbar, mark some text items as important 😉

Some icons might be self explanatory while others can be non-obvious, so this kind of feature will help people to preserve space and see text for icons which are not very straightforward.

Commenting closed.

Get started today with Qt Download now