Sign up for the KDAB Newsletter
Stay on top of the latest news, publications, events and more.
Go to Sign-up
Colin Ogilvie
17 December 2019
Back in February we wrote about our work to add 'MacOs touch bar' support to Qt. Between then and now, support has been added in QtCreator:
KDMacTouchBar in QtCreator
However, the changes have not been integrated upstream in Qt, which means there is still no easy way to add support to your own applications. KDAB is happy to provide this via KDMacTouchBar, available as both LGPL and commercial licence.
This provides touch bar support as a separate library, supporting both qmake and cmake as a build system. Support can be quickly added to any new or existing application using code similar to this example:
MainWindow::MainWindow()
{
setWindowTitle("KDMacTouchBar Example");
resize(400, 200);
// attach a touchbar to this window
KDMacTouchBar *touchBar = new KDMacTouchBar(this);
QIcon qtIcon(QStringLiteral(":qtlogo.png"));
// add item
QAction *action = new QAction(qtIcon, tr("Qt with touchbar"));
touchBar->addAction(action);
connect(action, &QAction::triggered, this, &MainWindow::activated);
// separator
touchBar->addSeparator();
touchBar->addSeparator()->setText(tr("More items:"));
// and more items
QAction *action1 = new QAction(tr("Item 1"));
touchBar->addAction(action1);
connect(action1, &QAction::triggered, this, &MainWindow::activated);
QAction *action2 = new QAction(tr("Item 2"));
touchBar->addAction(action2);
connect(action2, &QAction::triggered, this, &MainWindow::activated);
// make special escape button
QAction *quit = new QAction(tr("Quit"));
touchBar->setEscapeAction(quit);
connect(quit, &QAction::triggered, this, &QWidget::close);
}
KDMacTouchBar from example
There has also been some investigation into custom QML views within the touch bar, although this is not currently included in KDMacTouchBar. Stay tuned for news when it eventually comes out in the near future!
About KDAB
The KDAB Group is a globally recognized provider for software consulting, development and training, specializing in embedded devices and complex cross-platform desktop applications. In addition to being leading experts in Qt, C++ and 3D technologies for over two decades, KDAB provides deep expertise across the stack, including Linux, Rust and modern UI frameworks. With 100+ employees from 20 countries and offices in Sweden, Germany, USA, France and UK, we serve clients around the world.