[Interest] My experience porting to Qt5 (on OS X)
Till Oliver Knoll
till.oliver.knoll at gmail.com
Mon Sep 3 16:05:45 CEST 2012
2012/9/3 <morten.sorvig at nokia.com>:
> ...
> To expand a bit on this point: the key issue is that we can't offer exactly the same API as QToolBar has, for example no setOrientation or setMovable (not a big loss if you ask me). More serious might be that addWidget() becomes harder to support.
I have never needed so far to use addWidget() for a QToolBar. However
I thought about it to add my own custom "Segmented PushButton Widget"
to a toolbar. That would not be possible then.
However I just saw how others do it, e.g. in the Java FX world:
http://fxexperience.com/2012/02/customized-segmented-toolbar-buttons/
(I am not saying that this is the best possible solution - but you get
the idea what I mean with "Segmented Button")
So they basically take a bunch of normal Buttons to a HBox layout
(within a ToolBar) and apply some CSS wizardy to it: squeezing all
buttons together and add rounded corners to the first and last Button.
So coming back to our QtMacUnifiedToolBar (or to QToolBar in general):
would a similar approach be possible, that is without implementing a
custom "MySegmentedToolBarButton" and addWidget(), but by merely
playing around with the layout of the added QActions? I imagine
something like making them adjacent to each other (without any gap),
and provide the proper icons would already be fine (I mean that I am
responsible myself that the right and left outermost buttons would
have the proper rounded icon).
If that is the case personally I would not miss the addWidget() functionality.
> Here's a snippet from sample code using the new toolbar class:
>
> QtMacUnifiedToolBar toolBar;
So I found this:
http://labs.qt.nokia.com/2011/04/08/mac-toolbars-for-qt-quick/ :)
I wouldn't mind implementing a "platform-wrapper" across QToolBar and
QtMacToolBar which would provide whatever API the application would
need (e.g. setting the visibility of the toolbar).
I understand QtMacUnifiedToolBar is really an NSToolBar. Now since I
am to write platform-dependent code anyway, would it also be easily
possible to access the underlying NSToolBar and mess around with it
with the Cocoa API, e.g. add a "Cococa segmented buttons widget" (in
case that existed anyway, I am not an experienced Cocoa developer at
all)?
And last but most interesting question for me: is QtMacUnifiedToolBar
already present (maybe as a private API only) in the Qt 5 Beta 1, so I
can play around with it a little? :)
Cheers, Oliver
More information about the Interest
mailing list