Better_Software_Header_MobileBetter_Software_Header_Web

Find what you need - explore our website and developer resources

KDMacTouchBar

A quick introduction

KDMacTouchBar in QtCreator

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

About KDAB