The touchbar is a touch-sensitive OLED strip sitting above the standard keyboard, where the function keys used to be. macOS uses it for some of the physical buttons that used to be located there, such as volume controls, but it is also possible to use the touchbar yourself, both as a graphical output device, and to trigger various activities.
Not a lot of packaged software makes use of it yet, but of course Apple's own applications as well as recent versions of Microsoft Office and various Adobe packages use this to the fullest.
Support for Qt Developers
Qt developers were left out up until now, since there was no support in Qt for this.
This is a welcome addition since Apple is not making interfacing with its system components from C++ particularly easy. This requires code written in Objective-C, one of Apple's favorite programming languages, to interface with the built-in Cocoa libraries, as well as the necessary glue code written in C++ to make the touchbar appear as a perfectly ordinary Qt widget to Qt applications.
Currently supported are QTabBar, QMessageBox, QDialogButtonBox (Apple is using the touchbar a lot to show the buttons that close a dialog, such as "OK" and "Cancel"), and QWidgetAction, and it is possible to mark a QAction as the principal action as well as the escape action. Action icons are already supported, and further additions are planned.
Until QMacTouchBar has been merged upstream, you can find it here.
5 Comments
22 - Feb - 2019
Will
Is there any way to do custom painting on the touchbar, or get touch events?
27 - Feb - 2019
Matthias Kalle Dalheimer
Hello, yes, and it's quite easy. You can use QWidgetAction and thus any widget that you can paint on. Touch events come to the widget delivered as mousePress/mouseMove/mouseRelease events, however, only the x coordinate will be valid, the y coordinate will always be the center of the touchbar.
22 - Mar - 2019
Nikhil
The Patch status now says Abandoned.
25 - Mar - 2019
Matthias Kalle Dalheimer
Sadly, The Qt Company staff did not feel this was a valuable addition to Qt and refused to merge it. We have now made the code available at https://github.com/KDAB/KDMacTouchBar.
1 - Apr - 2022
Kali Leo
Thanks for this, I was waiting for it from Qt. It is still very usefull, there are so many MacBooks with Touchbar out there.