C

Application Class

class Qul::Application

The Application class is used to start Qt Quick Ultralite. More...

Header: #include <qul/application.h>
Since: Qt Quick Ultralite 1.2

Public Functions

Application(const Qul::ApplicationConfiguration &applicationConfigs)
void exec()
void setRootItem(Qul::RootItem *root)
Qul::ApplicationSettings &settings()
const Qul::ApplicationSettings &settings() const
uint64_t update()

Static Public Members

void addImageProvider(const char *providerId, Qul::ImageProvider *provider)

Detailed Description

Construction of this class initializes Qt Quick Ultralite. Typically it is constructed in the main() function, the item shown at startup is set with setRootItem() and exec() is then called to enter the event loop. Hardware must be initialized by Qul::initHardware() or your own code. Before entering the event loop, Qt Quick Ultralite platform must be initialized by Qul::initPlatform(). For example if the root item defined in QML is called Main:

Qul::initHardware(); // Optional
Qul::initPlatform();
Qul::Application app;
static struct Main item;
app.setRootItem(&item);
app.exec();

See also Entry point to Qt Quick Ultralite application.

Member Function Documentation

Application::Application(const Qul::ApplicationConfiguration &applicationConfigs)

Alternate constructor for Application class with Qul::ApplicationConfiguration instance as argument. Text cache settings such as text cache enable and text cache size are configured with the use of this constructor instead of default one.

[static] void Application::addImageProvider(const char *providerId, Qul::ImageProvider *provider)

Sets the provider to be used for requesting images via the image:// url scheme, with host providerId .

The Application does not take ownership of the provider .

See the ImageProvider documentation for details on implementing and using image providers. All required image providers must be added to the engine before any QML sources files are loaded.

The providerId must be null-terminated.

void Application::exec()

Enters Qt Quick Ultralite event loop and does not return.

void Application::setRootItem(Qul::RootItem *root)

Sets the item shown at application startup to be root. The items are defined in QML and the struct that represents them in C++ is defined in a generated header, which has the same name as the .qml file.

Qul::ApplicationSettings &Application::settings()

Returns a convenient ApplicationSettings object through which Application is configured.

const Qul::ApplicationSettings &Application::settings() const

This is an overloaded function.

[since Qt Quick Ultralite 1.8] uint64_t Application::update()

Updates the Qt Quick Ultralite core engine

When implementing the main loop inside the application code, this function is used to update Qt Quick Ultralite core engine. Returns the timestamp when the Qt Quick Ultralite core engine is expecting to be called next time. A timestamp lesser than the current timestamp, or even 0, should result in calling update() as soon as possible. A greater timestamp value than the current timestamp means that the platform implementation should call update() at that given time. Until the scheduled time, the device may enter a sleep mode.

When using exec() this is not needed.

Qul::initHardware();
Qul::initPlatform();
Qul::Application app;
static MainScreen item;
app.setRootItem(&item);
while (true) {
    auto now = Qul::Platform::getPlatformInstance()->currentTimestamp();
    // <handle timers>
    auto nextUpdate = app.update();
    if (nextUpdate > now) {
        // Device can go to sleep until next update is due

        // enterLowPowerMode(nextUpdate - now);
    }
}

This function was introduced in Qt Quick Ultralite 1.8.

See also exec().

Available under certain Qt licenses.
Find out more.