Pages
API Documentation
On this page

KirigamiAppDefaults Namespace

Contains a function to apply useful default Qt options for Kirigami apps. More...

  • Header: #include <KirigamiAppDefaults>
  • CMake: find_package(KF6 REQUIRED COMPONENTS KirigamiAddons)
    target_link_libraries(mytarget PRIVATE KF6::KirigamiAddons)

Detailed Description

Function Documentation

void KirigamiAppDefaults::apply(QGuiApplication *app)

Helper to apply suitable defaults for an app using Kirigami

Kirigami apps are generally Qt apps using Kirigami. Qt's defaults and fallbacks on different platforms don't fit these apps very well. This function sets up the default style to Breeze, sets up support for color schemes, sets the Breeze icon theme, sets a font size and configures logging and crash handling.

Your normal main function should look something like

int main(int argc, char *argv[])
{
    QApplication app(argc, argv);
    KirigamiAppDefaults::apply(&app);

    // Set up KAboutData

    // QCommandLineParser creation and processing

    QQmlApplicationEngine engine;
    KLocalization::setupLocalizedContext(&engine);
    if (!KirigamiAppDefaults::load("org.kde.myapp", u"Main", &engine)) {
        return EXIT_FAILURE;
    }
    return app.exec();
}

bool KirigamiAppDefaults::load(QAnyStringView uri, QAnyStringView typeName, QQmlApplicationEngine *engine)

Loads the QML module and displays its loading errors if startup fails.

On desktop platforms, the errors are shown in a native message box. On Android, a Qt Quick dialog is used so this helper does not require Qt Widgets.

Returns true when the requested module or fallback error UI loaded successfully.

We use cookies to personalize content and to analyze our traffic. Please decide if you are willing to accept cookies from our website.