Say hello to qpm. A package manager for Qt/QML!

Over the past few years we have been fortunate enough to try quite a few different technologies outside the world of Qt. We've done native development for iOS, Android and Windows Phone and more recently have done some stuff on the web. After using these other platforms, we noticed that they all had something that Qt did not: a package manager for handling application dependencies.

Back in August we decided that we would try to make a prototype to see how far we could get in a few weeks. A few weeks turned into a few months and today we have something that we are reasonably happy with. We bought a spiffy domain, a slick HTML template and a DigitalOcean droplet. When you put it all together you get qpm.io!

qpm is a command line tool for installing and managing dependencies for your application. It is based around Qt's .pri file support so everything gets compiled into your application binary. No libraries, no plugins, no qt.conf, no deploying QML/JS files. Everything gets rolled into your app for easy deployment. The tool itself follows the same principal. It's a single static binary executable with no dependencies, no config files, and no environment variables.

Get it

Believe it or not, one of the things we struggled with the most was how to distribute a single command line binary to the 3 main desktop platforms. We're still evaluating the best way to do this, but head over to qpm.io to see what's available now, but also leave a comment about how you would like to get it.

Try it

So let's say you have an app and you want to use a 3rdparty package that is available in qpm. You should navigate to the source root of your project and install what you want ("qpm list" lists all packages in the registry) :

> qpm install io.qpm.example
Installing [email protected]

This command will create the following files and directories:

- qpm.json
- vendor/
  +- vendor.pri
  +- io/
     +- qpm/
        +- example/
           +- *code*

The qpm.json file is used purely for tracking your dependencies. Your are not expected to publish your applications to qpm :)

The vendor/ directory is created and maintained by qpm and used to store the dependencies. Everything in here is generated so it's probably best not to put things here.

The vendor.pri file is the file that you need to include in your application's .pro file.

The io/qpm/example path is the directory where the code for the package is extracted.

Ok, now that it is installed, you are ready to use the newly installed package in your application. In your main.cpp:

QQmlApplicationEngine engine;
QPM_INIT(engine) // <-- ADD THIS LINE
engine.load(QUrl(QStringLiteral("qrc:/main.qml")));

QPM_INIT is just a macro that adds "qrc:/" to your QML import path. QML should live in a resource file (with a proper prefix) so that's why this is required. It might disappear in the future if we can do something suitable in Qt itself. Finally in your QML code you can do this:

import io.qpm.example 1.0

HelloQpm {
...
}

And that's it! Adding new packages will simply be a matter of installing them and importing them. Packages support C++, Javascript and of course QML. It's worth mentioning that packages can also be used in Qt C++ apps (ie: without QML).

More Info

The website can be found here: https://www.qpm.io.

The source code for the client (and the docs) is here: https://github.com/Cutehacks/qpm.

And finally the roadmap is here: https://trello.com/b/ofOIyRR0/qpm-roadmap

If you are at Qt World Summit 2015, check out Jens' Lightening Talk!