Skip to content

QMacTouchBar has landed KDAB contributes the widget in QtMacExtras

QMacTouchBar has landed

Recent Apple MacBook Pro models contain an entirely new hardware feature, the touchbar. 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 has now changed, however, since KDAB just contributed QMacTouchBar, a widget in the QtMacExtras module that was written by KDABian Christoph Schleifenbaum, and that is already being used in some of KDAB’s own internal tools.

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.

FacebookTwitterLinkedInEmail

2 thoughts on “QMacTouchBar has landed”

    1. 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.

Leave a Reply

Your email address will not be published. Required fields are marked *

By continuing to use the site, you agree to the use of cookies. More information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.

Close