LoginSignup
5
4

More than 3 years have passed since last update.

Qt Creator で Raspberry Pi3 向けのアプリケーションを開発しよう

Last updated at Posted at 2019-06-17

はじめに

先日 Raspberry Pi 3 で Qt 5 をビルドして動かす方法 という記事を書き、Raspberry Pi 上で Qt アプリを開発するための準備をしました。

今回は、Qt Creator を利用して、実際にアプリケーションを書いて、実機上で動かしてみましょう。

Qt Creator の設定

クロスコンパイラの登録

Option > Kits > Compilers を開き、クロスコンパイラの用意 で用意したものを登録します。
Screenshot_20190618_004313.png
~/com/github/raspberrypi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x86/bin/arm-linux-gnueabihf-gcc
Screenshot_20190618_004401.png
~/com/github/raspberrypi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x86/bin/arm-linux-gnueabihf-g++
Apply をクリックして、設定を反映させます。

デバッガの登録

同じように gdb も登録したいところですが、raspbian が提供している gdb は Python がサポートされていないため、Qt Creator からは利用できませんでした。
Screenshot_20190615_005816.png
~/com/github/raspberrypi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x86/bin/arm-linux-gnueabihf-gdb

Qt の登録

Qt のビルド でインストールした qmake を登録します。
Screenshot_20190618_010657.png
Apply をクリックして、設定を反映させます。

デバイスの登録

Devices を選択し、 Add... をクリックします。
Screenshot_20190618_012105.png
Generic Linux Device を選択し、Start Wizard をクリックします。
Screenshot_20190618_012137.png
任意の名前と、IPアドレス、デバイスにログインするユーザー名を入力し、Next > をクリックします。
Screenshot_20190618_012156.png
ssh の公開鍵をデバイスに転送し、Next > をクリックします。
Screenshot_20190618_012207.png
デバイスを登録する準備は完了です。Finish をクリックします。
Screenshot_20190618_012221.png
接続テストが行われます。Close で閉じましょう。
Screenshot_20190618_010759.png
Apply をクリックして、設定を反映させます。

Kit の作成

Screenshot_20190618_012957.png
一通りの情報を選択・設定します。
OK ボタンで設定は完了です。

アプリケーションの作成

では、早速アプリケーションを作ってみましょう。

と言いたいところですが、ここでは、既存のアプリケーションを動かすことにします。

Qt Creator で、File > Open File or Project... をクリックし、Import Project > Git Clone を選択し、Choose... をクリックします。
Screenshot_20190618_015040.png
git@github.com:task-jp/weather.git (もしくは https://github.com/task-jp/weather.git) を任意のディレクトリにクローンします。
Screenshot_20190618_015313.png
Screenshot_20190618_015353.png
先ほど作成した Raspberry Pi3 向けの Kit を有効にしましょう。
Screenshot_20190618_015421.png
Raspberry Pi3 の Kit でビルドをし、実行してみましょう!
Screenshot_20190618_022929.png
55b310bf-1d42-444e-93b3-53ac2a184d29.jpeg

おわりに

Qt Creator に Raspberry Pi3 向けの設定をし、ボタン一つで実機上でアプリケーションを動作させることができました。

gdb の設定の関係で、C++ のデバッグはできていない状態ですが、QML のデバッガは利用可能になっています。

是非、色々作って実機上でサクッと動かしてみてください。

5
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
4