Skip to content
This repository has been archived by the owner on Jul 17, 2023. It is now read-only.
/ qtstatusbar Public archive

StatusBar for Qt allows setting the status bar color and theme on Android and iOS.

License

Notifications You must be signed in to change notification settings

jpnurmi/qtstatusbar

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

StatusBar for Qt

StatusBar for Qt allows setting the status bar color [1] and theme [2] on Android and iOS.

Android

screenshot

  1. NOTE: StatusBar::color requires Android 5.0 Lollipop (API level 21) or later.
  2. NOTE: StatusBar::theme requires Android 6.0 Marshmallow (API level 23) or later.

iOS

screenshot

It is recommended to set the Qt.MaximizeUsingFullscreenGeometryHint window flag, and take the difference between Screen.height and Screen.desktopAvailableHeight into account. For example:

ApplicationWindow {
    flags: Qt.Window | Qt.MaximizeUsingFullscreenGeometryHint

    header: ToolBar {
        topPadding: Qt.platform.os === "ios" ? Screen.height - Screen.desktopAvailableHeight : 0
    }
}
  1. NOTE: StatusBar::color is not available on iOS.

Build

The easiest way to include StatusBar to a project is to copy over the contents of the src folder and include statusbar.pri in the project file (see example/statusbar.pro):

include(path/to/statusbar.pri)

Register

Registering the QML type in C++ (see example/main.cpp):

#include "statusbar.h"

int main(int argc, char* argv[])
{
    QGuiApplication app(argc, argv);

    qmlRegisterType<StatusBar>("StatusBar", 0, 1, "StatusBar"); // <==

    QQmlApplicationEngine engine;
    engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
    
    return app.exec();
}

Usage

Example usage in QML (see example/main.qml):

import StatusBar 0.1

StatusBar {
    theme: StatusBar.Dark // or Material.Dark
    color: Material.color(Material.Indigo, Material.Shade700)
}