Mr17MG / QtStatusBar

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

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

qmake:

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)
    INCLUDEPATH += ../QStatusBarLib/include

CMake:

see example/CMakeLists.txt:

    include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../QStatusBarLib/include)
    
    target_link_libraries(
        ${PROJECT_NAME} PRIVATE
        ${QStatusBarLib}
    )

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)
}

About

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

License:MIT License


Languages

Language:C++ 51.0%Language:QML 17.8%Language:Objective-C++ 16.9%Language:CMake 11.7%Language:QMake 2.5%