Rust and QML on Xubuntu

I just spotted A simple Rust GUI with QML on r/rust and wanted to give it a try. I already had Rust installed, but not QML. My desktop computer is currently running Xubuntu, which is Ubuntu with Xfce. Xfce is based on GTK+, whereas QML is based on Qt. There is a Kubuntu, which is Ubuntu with KDE. Since KDE is based on Qt, it probably has all the stuff we need for QML already. But we needn’t switch to Kubuntu to install QML. We can install it on Xubuntu or any version of Ubuntu just fine 1.

To install QML, I ran

sudo apt install qtdeclarative5-dev qml-module-qtquick-controls

which installed a whole bunch of dependencies, since I had no Qt things at all on this box yet. This got “Hello, World” to work, but there was not enough whitespace.

Screen shot of "hello world" in QML

Figure 1: “hello world” in QML!

I added width and height attributes to the .qml file and changed anchors.fill to anchors.centerIn

ApplicationWindow {
    visible: true
    width: 200
    height: 100
    Text {
        anchors.centerIn: parent
        text: message
    }
}

This looked a little better.

Screen shot of "hello world" with whitespace added

Figure 2: “hello world” with whitespace added

I probably should have made the font bigger as well, but I didn’t want to go too far down the “pointy-clicky nonsense” rabbit hole.

Later in the exercise, I needed QtQuick.Dialogs as well. For that, I ran

sudo apt install qml-module-qtquick-dialogs

Anyway, it’s a fun little blog post…you should give it a try! Bottom line is, Ubuntu has everything we need to follow along with it, even if the names aren’t that obvious.

Footnotes:

1

Indeed, renaming the distribution after the window manager like this is my least favorite thing about Ubuntu. I appreciate easy access to Xfce, but I didn’t need a whole new name. Xubuntu, Kubuntu, Lubuntu,…gah!

Advertisements
Rust and QML on Xubuntu

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s