Create Qt on Raspberry Pi

From Qt Wiki
Revision as of 15:11, 14 January 2015 by Maintenance script (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Qt on Raspberry Pi — Create

QtonPi App SDK

QtonPi Release-0.x App SDK consists of,

  • Qt Creator
  • Sysroot + Toolchain

As indicated in the roadmap, we hope to have a more integrated App SDK from Release-1.x onwards.

Download

QtonPi releases are distributed via BitTorrent. QtonPi download page is here.

Upon downloading a QtonPi release, you should see a tarball

qtonpi-X.Y.tar.bz2

, where

X

is the major release number and

Y

is the minor release.

QtonPi release directory is organized as follows,

Following is a brief description of the directory structure,

app-sdk/
Application SDK
platform-sdk/

‘‘Platform SDK – In case you would like to roll your own SD Card Image and/or Sysroot. See Contribute section for more details’‘

sdcard-img/
‘‘Default SD Card Image – Please use this for reporting bugs!’‘

Install

Qt Creator

First step would be to install Qt Creator. You will find Qt Creator installer here, (Note: This is not necessary if you have an updated Qt SDK installed. Just use your current Qt Creator and follow the instructions from Toolchain and Sysroot)

To install, just run the

qt-creator-linux-x86-opensource-2.x.y.bin

file

This should install, launch Qt Creator. In addition, it’ll also create an icon on your Desktop.

Toolchain and Sysroot

Next step would be to install the toolchain and default sysroot. You can find it here,

You will need to extract this as

root

user, into the

root(/)

directory of your filesystem.

Qt 5

QtonPi ships with a known working (necessarily not stable!) version of Qt 5. This version works both on the sysroot and the target and you can find it here, (Note: This does not play nicely with another Qt5 install. For instance if you already have Qt5 installed for x86 development. This should be resolved in the 1.x release)

You will need to extract this as

root

user, into the

root(/)

directory of your filesystem.

SD Card Image

In addition, there is also a default 2GB SD Card Image, with Qt 5 on it. You’ll find it here.

To setup your SD card,

cat/dd

the contents of this file onto your SD Card. Assuming your SD Card device is

/dev/sdb

, one way to do this is as follows. Note you’ll need to be logged in as

root

in order to be able to write to

/dev/sdb

device. You’re now ready to boot your Raspberry Pi Device! There are two accounts –

root

and

qtonpi

. Password for the accounts are

rootme

and

qtonpi

respectively. Upon booting and logging into your Raspberry Pi device as

root

, you’ll need to enable networking (which is disabled by default!). If you’ve DHCP setup, find out the ethernet interface of your Raspberry Pi device by doing

ifconfig -a

and run

dhclient eth0

on that interface.

dhclient

usually does a lousy job at giving useful information. So, once you are back on the command prompt, do an

ifconfig -a

to see if an IP Address got assigned. In the above example, eth0 has an IP address of 10.48.194.196. Then update the date/time on Raspberry Pi device. This can be done easily using

ntpdate

Configuring Qt Creator, Toolchain, Qt 5 and Raspberry Pi board

Connecting Qt Creator to Raspberry Pi board

By this time you should be able to ssh from your host machine (running Qt Creator) into your Raspberry Pi Board. If you are not able to do so, please check your network connectivity before proceeding any further!

  1. Launch Qt Creator and select Tools -> Options -> Linux Devices
  2. Click Add and select Generic Linux Device. Then Click on Start Wizard
  3. Enter the following in the dialog box that appears
    • The name to identify this configuration:
      Raspberry Pi
      
    • The device’s hostname or IP address : ‘‘IP Address of your Raspberry Pi device’‘
    • The user name to log into the device:
      root
      
    • The authentication type: ‘‘Select Password’‘
    • The user’s password:
      rootme
      
  4. Click Next followed by Finish
  5. The Device Test should finish successfully. If not, go back and check your network connectivity and other settings.

Setting up your toolchain

  1. In Qt Creator, select Tools -> Options -> Build & Run and Tool Chains tab
  2. Select Manual and click on Add
  3. In the dropdown menu, select GCC
  4. Then select GCC, as it appears below Manual and specify the ‘‘Compiler path:’‘ as ‘’/opt/qtonpi/bin/armv5tel-qtonpi-linux-gnueabi-gcc’‘ and ‘‘Debugger:’‘ as ‘’/opt/qtonpi/bin/armv5tel-qtonpi-linux-gnueabi-gdb’‘
  5. Click on Apply and select OK

Selecting Qt 5 for Raspberry Pi

  1. In Qt Creator, select Tools -> Options -> Build & Run and Qt Versions tab
  2. Select Manual and click on Add…
  3. Then select
    qmake
    
    file located in ‘’/opt/qt5/bin/qmake’‘ and click on Open
  4. Click on Apply and select OK

Qt creator might indicate “Qt version 5.0.0 for Desktop”, which can be safely ignored for now.

Hello QtonPi!

QtonPi App SDK comes with

hello-qtonpi

App to get you started with Qt 5, which is located here,

Feel free to extract the tarball anywhere in your home directory.

Next launch Qt Creator (if you don’t already have it running!), and do the following.

  1. Select File -> Open File or Project…, navigate to
    hello-qtonpi/hello-qtonpi.pro
    
    and click Open
  2. When you do this first time, Project Setup Dialog appears for the Target Setup, with sane defaults. Select Finish
  3. In the side-bar, select Projects mode or press Control-5, and go into Run Settings
  4. In the Deployment section, click on Add and select Deploy to Remote Linux Host
  5. In Device Configuration you should see ‘‘Raspberry Pi (Default)’‘
  6. In the Run section, click on Add and select hello-qtonpi (on Remote Generic Linux Host)
  7. At this point, you should be all set to roll. In the side-bar, select Edit mode or press Control-2
  8. To build your project, select Build -> Build All. This should build the binary using QtonPi toolchain.
  9. Next step would be deploy your binaries onto your Raspberry Pi Device. To do this, select Build -> Deploy All. Your Raspberry Pi device should now have
    hello-qtonpi
    
    executable in
    /root/hello-qtonpi
    
    directory.
  10. To run your newly minted App, select Build -> Run, and at this point you should see your Qt 5 Qt Quick App running on your display

Now that you’ve a working QtonPi SDK, next step would be to learn more about Qt Quick. Following are some resources to help you get started.

Uninstall

Release 0.x of QtonPi SDK consists of three parts, which you’ll need to uninstall separately.

  1. Qt Creator
  2. Qt 5
  3. QtonPi Toolchain and Sysroot

Note – * If you are updating between 0.x releases, you *do not have to uninstall Qt Creator each time.

Qt Creator

In order to uninstall Qt Creator, go to the

bin/

directory in your Qt Creator installation and execute the

uninstall

command.

Toolchain and Sysroot

Uninstalling the toolchain and sysroot is as simple as removing the

/opt/qtonpi/

directory.

Should take care of it!

Qt 5

Likewise, to uninstall Qt 5, remove

/opt/qt5/

directory.

Categories: