Git Product home page Git Product logo

qmlreloader's Introduction

QML reLoader

English | Português (Brasil)

Overview

The QML reLoader allows developers to quickly reload the user interface on every document save by watching the hierarchy of loaded files when using the Qt's Loader component. The main difference between this and other solutions is that we will not reload the entire application, but only the parts that have been changed (and their dependencies). It is aimed to speed up development in small to big projects.

It supports Linux, macOS and Windows. It has been tested with Qt 5.12 through 5.15. MIT Licensed.

Demo

QML reLoader in action

How to use it

There are three steps:

1: Add the folder qmlreloader/ to your project and include the qmlreloader.pri in your ".pro"ject file:

QT += quick

CONFIG += c++11 silent

INCLUDEPATH += $$PWD

SOURCES += \
    $$PWD/main.cpp

RESOURCES += \
    $$PWD/qml.qrc

# QML reLoader
include($$PWD/../qmlreloader/qmlreloader.pri)```

2: Include the header qmlreloader.h in your main.cpp, and after the Engine declaration, register it with the QML reLoader:

#include <QGuiApplication>
#include <QQmlApplicationEngine>

/// Include the header
#include "qmlreloader.h"

int main(int argc, char *argv[])
{
    QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);

    QGuiApplication app(argc, argv);

    QQmlApplicationEngine engine;
    
    /// Register the engine within QML reLoader
    QMLreLoader::QMLreLoader reloader(&engine);

    const QUrl url(QStringLiteral("qrc:/main.qml"));
    QObject::connect(&engine, &QQmlApplicationEngine::objectCreated,
        &app, [url](QObject *obj, const QUrl &objUrl) {
            if (!obj && url == objUrl)
                QCoreApplication::exit(-1);
        }, Qt::QueuedConnection);
    engine.load(url);

    return app.exec();
}

3: On every usage of the traditional Qt QML Loader, register it within QML reLoader on the Component.onCompleted {} signal, and you're done:

Loader {
    id: loadCRM

    anchors.fill: parent
    source: "qrc:/modules/crm/StartCRM.qml"

    Component.onCompleted: {
        reloader.registerLoader(loadCRM); // this loader will now be monitored
    }
}

Copyright (c) 2020 Arthur Turrini.

qmlreloader's People

Contributors

turrini avatar

Stargazers

brillian avatar Boolean avatar 康立勇 avatar Serhii Olendarenko avatar  avatar  avatar Heraldo Gama avatar  avatar  avatar GoPlayEgg avatar  avatar Mutalisk avatar xiaodao avatar Patrick José Pereira avatar Sultan Al Isaiee avatar Berkant avatar qyvlik avatar Petr Mironychev avatar M. Galib Uludag avatar Alberto Bignotti avatar ZiLin Chen avatar Bancha Rajainthong avatar CGinMax avatar  avatar Olivier Le Doeuff avatar Furkan Üzümcü avatar Matheus C. França avatar

Watchers

 avatar  avatar

Forkers

eswizardry

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.