Sitara Linux Training: Hands on with QT - Компэл · 2019-08-02 · Sitara Linux Training:...

33
Sitara Linux Training: Hands on with QT 1 Sitara Linux Training: Hands on with QT Introduction This lab is going to give you a hands on tutorial on QT, the GUI devolpment tool, which is a component of the Sitara SDK. Each of the following sections below will walk you through a particular Lab exercise, the key points to take away, and the step-by-step instructions to complete the lab. The labs in this section will utilize both a command line build approach and a IDE approach using QT Creator. Hands On Session: - In the vmware image, there are cheater files: /home/sitara/QT_Lab You can cut and paste section of code from this file rather than have to type them in. You can find a copy here, just right click and select "Save Target As": Wiki Training: - You can find the necessary code segments embedded in the this wiki article. You can cut and paste them from the wiki as needed. NOTE: In this guide commands to be executed for each step will be marked in BOLD Lab Configuration The following are the hardware and software configurations for this lab. The steps in this lab are written against this configuration. The concepts of the lab will apply to other configurations but will need to be adapted accordingly. Hardware AM335x EVM-SK (TMDSSK3358) - Order Now [1] NOTE All Sitara boards with an LCD display or HDMI/DVI out can be used for these labs, but the steps below related to serial and ethernet connections may differ. Router connecting AM335x EVM-SK and Linux Host USB cable connection between AM335x EVM-SK and Linux Host using the micro-USB connector (J3/USB0) NOTE The AM335x EVM uses a standard DB9 connector and serial cable. New Win7 based Host PCs may require a USB-to-Serial cable since newer laptops do not have serial ports. Additionally, since an Ethernet connection is not required for these labs, you can telnet or ssh into the target instead of using a serial terminal for target interaction. 5V power supply (typically provided with the AM335x EVM-SK)

Transcript of Sitara Linux Training: Hands on with QT - Компэл · 2019-08-02 · Sitara Linux Training:...

Page 1: Sitara Linux Training: Hands on with QT - Компэл · 2019-08-02 · Sitara Linux Training: Hands on with QT 1 Sitara Linux Training: Hands on with QT Introduction This lab is

Sitara Linux Training: Hands on with QT 1

Sitara Linux Training: Hands on with QT

Introduction

This lab is going to give you a hands on tutorial on QT, the GUI devolpment tool, which is a component of the SitaraSDK. Each of the following sections below will walk you through a particular Lab exercise, the key points to takeaway, and the step-by-step instructions to complete the lab. The labs in this section will utilize both a command linebuild approach and a IDE approach using QT Creator.Hands On Session: - In the vmware image, there are cheater files: /home/sitara/QT_Lab You can cut and pastesection of code from this file rather than have to type them in. You can find a copy here, just right click and select"Save Target As":Wiki Training: - You can find the necessary code segments embedded in the this wiki article. You can cut and pastethem from the wiki as needed.NOTE: In this guide commands to be executed for each step will be marked in BOLD

Lab ConfigurationThe following are the hardware and software configurations for this lab. The steps in this lab are written against thisconfiguration. The concepts of the lab will apply to other configurations but will need to be adapted accordingly.

Hardware• AM335x EVM-SK (TMDSSK3358) - Order Now [1]

NOTEAll Sitara boards with an LCD display or HDMI/DVI out can be used for these labs, but the steps belowrelated to serial and ethernet connections may differ.

• Router connecting AM335x EVM-SK and Linux Host• USB cable connection between AM335x EVM-SK and Linux Host using the micro-USB connector (J3/USB0)

NOTEThe AM335x EVM uses a standard DB9 connector and serial cable. New Win7 based Host PCs may require aUSB-to-Serial cable since newer laptops do not have serial ports. Additionally, since an Ethernet connection isnot required for these labs, you can telnet or ssh into the target instead of using a serial terminal for targetinteraction.

• 5V power supply (typically provided with the AM335x EVM-SK)

Page 2: Sitara Linux Training: Hands on with QT - Компэл · 2019-08-02 · Sitara Linux Training: Hands on with QT 1 Sitara Linux Training: Hands on with QT Introduction This lab is

Sitara Linux Training: Hands on with QT 2

Software• A Linux host PC configured as per the Linux Host Configuration [2] page• Sitara Linux SDK installed. This lab assumes the latest Sitara Linux SDK is installed in /home/sitara. If you use a

different location please modify the below steps accordingly.• SD card with Sitara Linux SDK installed.

• For help creating a 2 partition SD card with the SDK conent see the create_sdcard.sh script page• CCSv5 installed. This lab assumes CCS has been installed in /home/sitara. If you use a different location please

modify the below steps accordingly.• The CCS installer can be downloaded from the [http:/ / www. ti. com/ tool/ linuxezsdk-sitara [3]] page and if

extracted into the same directory as the SDK installer can be installed at the same time as the Sitara LinuxSDK using the SDK installer.

• QT Creator installed on your Linux host.• You can download Qt Creator from http:/ / get. qt. nokia. com/ qtcreator/ qt-creator-linux-x86-opensource-2. 4.

1. bin [4] if you do not already have it.

LAB 1: Hello World Command Line

DescriptionThis LAB is optional, it introduces where to find QT components and build tools in the Sitara SDK. Approximatetime to complete this LAB: 15 minutes. This section will cover the following topics• Introduction to build tools• enviroment setup script• The QT component of the Sitara SDK

• where to find things in the Sitara SDK

Key Points• Where in the SDK to find the build tools• Where in the SDK to find the QT components• How to setup your build environment• How to utilize the above points to create a Hello World application.

Lab Steps1. Connect the cables to the EVM. For details on where to connect these cables see the Quick Start Guide that came

with your EVM.1. Connect the Serial cable to provide access to the console.2. Connect the network cable3. Insert the SD card into the SD connector4. Insert the power cable into the 5V power jack

2. Power on the EVM and allow the boot process to finish. You will know when the boot process has finished whenyou see the Matrix application launcher on the LCD screen

NOTEYou may be required to calibrate the touchscreen. If so follow the on screen instructions to calibrate thetouchscreen.

3. Open a terminal window on your Linux host by double clicking the Terminal icon on the desktop

Page 3: Sitara Linux Training: Hands on with QT - Компэл · 2019-08-02 · Sitara Linux Training: Hands on with QT 1 Sitara Linux Training: Hands on with QT Introduction This lab is

Sitara Linux Training: Hands on with QT 3

4. The cross-compiler is located in the linux-devkit/bin directory of the SDK installation directory. In the terminalwindow enter the following commands, replacing the <machine> and <sdk version> fields with the targetmachine you are using and the SDK version installed.

NOTEYou can use TAB completion to help with this

• cd /home/sitara/ti-sdk-<machine>-<sdk version>/linux-devkit/bin• ls

5. You should see a listing of the cross-compile tools available like the one below.

6. To locate the pre-built ARM libraries perform the following commands:• cd /home/sitara/ti-sdk-<machine>-<sdk version>/linux-devkit/arm-arago-linux-gnueabi/usr/lib• ls

7. You should now see a listing of all the libraries (some are contained within their individual sub-directories)available as pre-built packages within the SDK.

8. Now list only the QT libraries from the same directory by listing all libs starting with libQt.• ls libQt*

9. You should see a listing of QT related libraries that can be used to build and run QT projects.

Page 4: Sitara Linux Training: Hands on with QT - Компэл · 2019-08-02 · Sitara Linux Training: Hands on with QT 1 Sitara Linux Training: Hands on with QT Introduction This lab is

Sitara Linux Training: Hands on with QT 4

10. You can also find out where the QT header files are located. At the directory below are sub directories full ofQT header files.• cd /home/sitara/ti-sdk-<machine>-<sdk

version>/linux-devkit/arm-arago-linux-gnueabi/usr/include/qtopia• ls

11. In order to make it easier to perform cross-compilations and ensure linking with the proper cross-compiledlibraries instead of the host system libraries the environment-setup script has been created in the linux-devkitdirectory. This script will configure many standard variables such as CC to use the cross-compile toolchain, aswell as adding the toolchain to your PATH and configuring paths for library locations. To utilize the settingprovided by the environment-setup script you will need to source the script. Perform the following commands tosource the environment-setup script and observe the change in the QMAKESPEC variable:• echo $QMAKESPEC• source /home/sitara/ti-sdk-<machine>-<sdk version>/linux-devkit/environment-setup• echo $QMAKESPEC

12. You should have observed that the QMAKESPEC variable now contains the path to the QMAKESPEC files.Additionally your compile tools were added. There was also another change that occurred which was that yourstandard prompt changed from sitara@ubuntu to [linux-devkit]. The purpose of this change is to make it easy toidentify when the environment-setup script has been sourced. This is important because there are times when youDO NOT want to source the environment-setup script. A perfect example is when building the Linux kernel.During the kernel build there are some applications that get compiled which are meant to be run on the host toassist in the kernel build process. If the environment-setup script has been sourced then the standard CC variablewill cause these applications to be built for the ARM, which in turn will cause them to fail to execute on the x86host system.

13. As mentioned above sometimes it is not appropriate to source the environment-setup script, or you only want tosource it during a particular build but not affect your default environment. The way this is done in the SDK is tosource the environment-setup script inside of the project Makefile so that it is used only during the build process.

Page 5: Sitara Linux Training: Hands on with QT - Компэл · 2019-08-02 · Sitara Linux Training: Hands on with QT 1 Sitara Linux Training: Hands on with QT Introduction This lab is

Sitara Linux Training: Hands on with QT 5

14. Take a look at the enviroment setup file to see what all is going on there. Look through file to see where thecompile tools variables such as CC and CPP and PATH are defined.• gedit /home/sitara/ti-sdk-<machine>-<sdk version>/linux-devkit/environment-setup

15. It is now time to build a Hello World project using QT. You need to create two files: helloworld.cpp andhelloworld.pro• mkdir /home/sitara/ti-sdk-<machine>-<sdk version>/example_applications/helloworld• cd /home/sitara/ti-sdk-<machine>-<sdk version>/example_applications/helloworld• gedit helloworld.cpp and add the following code

IMPORTANTYou can find pre-written files in the in the /home/sitara/sitara-training-helper-files/QT_Lab/lab1 directory.You can just copy those files to your directory instead of typing the contents if you want to

#include <QApplication>

#include <QLabel> int main(int argc, char **argv) {

QApplication app(argc,argv); QLabel label("Hello World"); label.show(); return app.exec();

} • gedit helloworld.pro and add code

IMPORTANTYou can find pre-written files in the in the /home/sitara/sitara-training-helper-files/QT_Lab/lab1 directory.You can just copy those files to your directory instead of typing the contents if you want to

QT += core gui

SOURCES += helloworld.cpp 16. Now lets use qmake to create a Makefile

• qmake helloworld.pro17. Notice how qmake automatically generated a Makefile for us, now lets build.

• make18. Notice the build is using our cross-compiler- arm-arago-linux-gnueabi-g++19. Also notice we now have an executable, lets see what type of file we created

• file helloworld20. You should see the following: helloworld: ELF 32-bit LSB executable, ARM, version 1 (SYSV), dynamically

linked (uses shared libs), for GNU/Linux 2.6.16, not stripped21. Finally lets copy the helloworld over to our target file system and run it.

• If you have not already done so connect with minicom and type ifconfig to find your target's ip addressNOTEYou can also get your ip address from Matrix if it is running. Select Settings->Network Settings

• On your Linux host console issue the command scp helloworld [email protected]:/home/root replacing thexx.xx.xx.xx below with you target's ip address.

• When asked for password, just hit return• Type yes when asked if you would like to continue

Page 6: Sitara Linux Training: Hands on with QT - Компэл · 2019-08-02 · Sitara Linux Training: Hands on with QT 1 Sitara Linux Training: Hands on with QT Introduction This lab is

Sitara Linux Training: Hands on with QT 6

• Move back over to your minicom window and execute it. You should find the helloworld in your default/home/root directory on the target.• ./helloworld -qws

22. Extra investigation:• What does the -qws do? Try running with and without adding the -qws.• Also try running with Matrix running and with Matrix not running.

• You can start and stop matrix with the following commands from minicom:/etc/init.d/matrux-gui2.0 start

/etc/init.d/matrix-gui2.0 stop

LAB 2: QT Creator Hello World

DescriptionThis section will cover setting up QT Creator the integrated development environment. We start to investigate howQT Creator aids in rapid GUI development.

Key Points• Setting up QT Creator to find your tools• Setting up QT Creator to communicate with the target platform• Creating hello world and run using QT Creator.

Lab Steps1. Source the enviroment setup file to ensure all the paths are setup correctly. This was done in the previous section.

If you already see [linux-devkit]: as your prompt then you can skip this step.• source /home/sitara/ti-sdk-<machine>-<sdk version>/linux-devkit/environment-setup

2. Bring up Qt Creator• /home/sitara/qtcreator-2.4.1/bin/qtcreator

IMPORTANTBy bringing QT Creator up manually, you will pass in the environment setup. If you double click on the QtCreator Icon from the Desktop, you will not have the enviroment setup correctly and your lab will not worklater on.

3. QT creator should be up and running now

Page 7: Sitara Linux Training: Hands on with QT - Компэл · 2019-08-02 · Sitara Linux Training: Hands on with QT 1 Sitara Linux Training: Hands on with QT Introduction This lab is

Sitara Linux Training: Hands on with QT 7

4. Now lets setup QT creator to configure qmake. From the QT creator main menu shown above select thefollowing:• Tools -> Options...• On the left side vertical menubar click Build & Run• Click the Qt Versions tab under Build & Run• Remove any versions that may already exist to make sure you start with a clean configuration• Click Add... on the right• Navigate to /home/sitara/ti-sdk-<machine>-<sdk version>/linux-devkit/bin• Select qmake then click on Open• Double click on Version Name and give the Qt Version a descriptive name such as QT 4.7.2 Sitara See

image below.

Page 8: Sitara Linux Training: Hands on with QT - Компэл · 2019-08-02 · Sitara Linux Training: Hands on with QT 1 Sitara Linux Training: Hands on with QT Introduction This lab is

Sitara Linux Training: Hands on with QT 8

IMPORTANTNotice there is a red ! icon. Don't worry, lets add in the toolchain next and it should change to yellow.

5. Now we will setup the toolchain• Click the Tool Chains tab under Build & Run• Click Add in the top right and add a GCC• Change the name to arm-arago-GCC. This can be done by double clicking on the Name GCC (the left GCC).• For Compiler Path select Browse

• Navigate to /home/sitara/ti-sdk-<machine>-<sdk version>/linux-devkit/bin• Select arm-arago-linux-gnueabi-gcc and click on open• Repeat the process to select a debugger, you will find it at the same location:

/home/sitara/ti-sdk-<machine>-<sdk version>/linux-devkit/bin/arm-arago-linux-gnueabi-gdb

Page 9: Sitara Linux Training: Hands on with QT - Компэл · 2019-08-02 · Sitara Linux Training: Hands on with QT 1 Sitara Linux Training: Hands on with QT Introduction This lab is

Sitara Linux Training: Hands on with QT 9

6. Now lets setup our Target. While still in the Tools -> Options menu• On the left side of the window, select the Linux Devices tab• In Linux Devices: click the Device Configurations tab• Click Add... in the top right and select Generic Linux device and click on Start Wizard• The Device Configuration Wizard Selection Dialog box comes up

• Change the name Generic Linux Device to give the device a unique name: AM335x EVM• Type in the IP address of the Embedded Linux Device. Type the IP address for your board, not the one

shown in the screen capture.NOTEThis is the same IP address you obtained in the previous lab• For Username type in root (Most Texas Instruments Boards have this username)• Make sure Authentication type is Password, but leave the password field blank.• Click Next and click Finish

Page 10: Sitara Linux Training: Hands on with QT - Компэл · 2019-08-02 · Sitara Linux Training: Hands on with QT 1 Sitara Linux Training: Hands on with QT Introduction This lab is

Sitara Linux Training: Hands on with QT 10

• You should see that the target test passed, so you can close that window.

7. Now we need to setup an SSH key so that the host can communicate with the target

Page 11: Sitara Linux Training: Hands on with QT - Компэл · 2019-08-02 · Sitara Linux Training: Hands on with QT 1 Sitara Linux Training: Hands on with QT Introduction This lab is

Sitara Linux Training: Hands on with QT 11

• Still under the Device Configurations tab click "Generate SSH Key.."• Select Key size: 1024• Key algorithm RSA• Then click Generate SSH Key in the SSH Key Configuration dialog box• Click Do not Encrypt key file• Then click Save Public Key...• Just use the default name id_rsa.pub and Click Save and Click Close to close the Generate SSH Key

window.• Under the Device Configurations tab now click Deploy Public Key...

• Select the file just generated (should be under /home/sitara/.ssh)IMPORTANTYou may need to right click and select show hidden files• Select the file id_rsa.pub and click on Open, shortly a window should show up saying "Deployment

finished sucessfully"

• Close the window and Click OK to exit the Linux Devices Window.8. Now that we are setup lets create a project build it and run it on the host

• Select File -> New File or Project• Then select QT Widget Project on the top left and QT GUI Application on the top right• Click on Choose• Type in the name of the project as terminal. We will be building on this project in the next section• Change the Create in value to /home/sitara• Click on Next

Page 12: Sitara Linux Training: Hands on with QT - Компэл · 2019-08-02 · Sitara Linux Training: Hands on with QT 1 Sitara Linux Training: Hands on with QT Introduction This lab is

Sitara Linux Training: Hands on with QT 12

• For Create Build Configuration: select Manually• Deselect Use Shadow Building, this is not needed• click Next

• Type in terminal for the Class name• In the Class Information window, select QWidget Base Class.• Click Next• ClickFinish

9. Now we've setup a new project lets explore and add some code.• Click on Edit on the left hand menubar and look at the project files including terminal.pro, main.cpp,

terminal.cpp and terminal.ui

• Under Forms, double click on terminal.ui This will bring up the widget editor.• Find the label widget in the category of display widgets, left click and drag it on to the User Interface (UI).

Page 13: Sitara Linux Training: Hands on with QT - Компэл · 2019-08-02 · Sitara Linux Training: Hands on with QT 1 Sitara Linux Training: Hands on with QT Introduction This lab is

Sitara Linux Training: Hands on with QT 13

• Type Hello World!!! into the label widget and strech out the borders so you can see all the letters.

10. Now we need to check and update the build and run settings:• On the left side vertical menubar select Projects• Select the Build Settings tab and selct the QT 4.7.2 Sitara(linux-devit) Debug for build configuration.

• Now under the Projects Mode select the Run Settings tab

Page 14: Sitara Linux Training: Hands on with QT - Компэл · 2019-08-02 · Sitara Linux Training: Hands on with QT 1 Sitara Linux Training: Hands on with QT Introduction This lab is

Sitara Linux Training: Hands on with QT 14

• Under Deployment click Add and select Deploy to Remote Linux Host• However you see the <no target path set> error.

• To fix the <no target path set> error do the following:• Click on Edit on the left side vertical bar and click on terminal.pro• Add the two lines below to the bottom of terminal.pro as shown in the screen shot belowIMPORTANTYou can find pre-written files in the in the /home/sitara/sitara-training-helper-files/QT_Lab/lab2 directory.You can just copy those files to your directory instead of typing the contents if you want to

target.path += /home/root

INSTALLS += target

Page 15: Sitara Linux Training: Hands on with QT - Компэл · 2019-08-02 · Sitara Linux Training: Hands on with QT 1 Sitara Linux Training: Hands on with QT Introduction This lab is

Sitara Linux Training: Hands on with QT 15

• Select File -> Save• Click on Projects on the left side vertical bar and you should now see the error is gone and replaced with

/home/root• Now in the Run portion: Select Add -> terminal (on Remote Generic Linux Host)

11. Finally we are ready to runIMPORTANTIf matrix is not running add -qws to the Arguments in Run Settings

• Click the Green Arrow on the bottom left to run the project• Save all files if asked

NOTETo exit from the hello world running on the target, click on the "X" on the upper right menu bar.

12. Extra Investigation:• From minicom: run top on the target while helloworld is running. Check out CPU utilization and memory

utilization for this simple app.• See how much memory is used by helloworld by itself, you may need to kill matrix /etc/init.d/matrix-gui-2.0

stop

Page 16: Sitara Linux Training: Hands on with QT - Компэл · 2019-08-02 · Sitara Linux Training: Hands on with QT 1 Sitara Linux Training: Hands on with QT Introduction This lab is

Sitara Linux Training: Hands on with QT 16

LAB 3: Terminal project

DescriptionThis section shows how you can use QT Creator to create a GUI from scratch.

Key Points• Adding widgets to a an User Interface (ui).• Adding code to make the widgets do something meaningful.

Lab Steps1. We will continue on from the previous lab using the terminal project you created. First we will remove the Hello

world widget and resize the ui.• Click terminal.ui to bring up design mode.• Click the Hello World widget, and delete it making the ui empty and clean

2. This next action is mainly for those with small displays, but will not adversely affect larger displays.• Select the entire ui as shown below.• Edit the Geometry values to Width = 440 and Height = 230 as shown.

3. Next we will add the Tab Widget. Just like the label widget, drag it over to the ui.

• Select the tab widget layout. Currently, the tab widget is part of our ui, but it is just sitting at fixed locationwhere we dragged it.• On the upper right side right click on the terminal QWidget and select Lay Out -> Lay Out Vertical as

shown below

Page 17: Sitara Linux Training: Hands on with QT - Компэл · 2019-08-02 · Sitara Linux Training: Hands on with QT 1 Sitara Linux Training: Hands on with QT Introduction This lab is

Sitara Linux Training: Hands on with QT 17

• Now the tab widget should completely fill the ui.4. Now let's ad

• Two Push Button Widgets• One Text Browser widget• One Line Edit widget.

• Drag all of them up to the ui• Now lets set the TabWidget layout like we did with the terminal widget

• Right click on the upper right QtabWidget -> Lay Out -> Lay Out in a Grid• Move them around so they look somewhat like the screen shot below

5. Lets Rename the Push Button widgets.• Double click on the PushButton text in the ui• Edit the upper push button to say Send CMD• Edit the lower push botton to say Exit• Depending on how the grid layout worked for you, lets stretch out the Text Browser widget and the bottom

Push Button widget to take up the whole screen horizontally if needed.• Just click on the widget and drag the border to fill the screen See screen shot below:

Page 18: Sitara Linux Training: Hands on with QT - Компэл · 2019-08-02 · Sitara Linux Training: Hands on with QT 1 Sitara Linux Training: Hands on with QT Introduction This lab is

Sitara Linux Training: Hands on with QT 18

6. Now lets give our widget objects a unique name.• Select the Text Browser widget• Go over to properties on the bottom right and edit ObjectName

• Add the text _linuxshell to the end of the textBrowser name as shown below:7. Now create unique names for the other 3 widgets.

• For lineEdit: lineEdit_commandline• For the Send CMD push button: pushButton_sendcmd• For exit push button: pushButton_exit

8. We are not done yet, but for fun lets run this application and see what it looks like on the target.• Push the Green Arrow at the bottom left to launch on the target. Save all files if asked.

IMPORTANTYou can not start a new application on the target if your previous one is still running. To exit, push the "X" onthe menubar at the top right of your target.NOTEIt should appear just as we designed it, but pushing the buttons has no effect because we haven't added anycode yet.

9. Now we are going to add code to make the buttons do what we wish them to do.• Right click on the Exit widget -> Go to slot• In the Go to Slot selector, select the first selection clicked() and hit OK

10. Notice this pops you over to your terminal.cpp file where some code has been automatically added for you.IMPORTANTThe code additions below can also be found in the /home/sitara/sitara-training-helper-files/QT_Lab/lab3directory and can be copied into your project

• Add the following line of code to on_pushButton_exit_clicked()

Page 19: Sitara Linux Training: Hands on with QT - Компэл · 2019-08-02 · Sitara Linux Training: Hands on with QT 1 Sitara Linux Training: Hands on with QT Introduction This lab is

Sitara Linux Training: Hands on with QT 19

qApp->quit();

11. Now repeat the same process you did for the exit button on the send CMD button. We will add code to controlthat button press.

NOTEYou will need to go back to the ui file to do this

• Right click on the Send CMD widget -> Go to slot• In the Go to Slot selector, select the first selection clicked() and hit OK• Add the following line at the top of terminal.cpp to support QProcess.

#include <QtGui>• Add the following code to on_pushButton_sendCmd_clicked()

QString LinuxTexttoSend = ui->lineEdit_commandline->text();

// QProcess used to binaries in /usr/bin QProcess process; // Merge Channels so the output of binaries can be seen process.setProcessChannelMode(QProcess::MergedChannels); // Start whatever command is in LinuxTexttoSend process.start(LinuxTexttoSend, QIODevice::ReadWrite); // Run the command and loop the output into a QByteArray QByteArray data; while(process.waitForReadyRead())

data.append(process.readAll()); ui->textBrowser_linuxshell->setText(data.data());

Page 20: Sitara Linux Training: Hands on with QT - Компэл · 2019-08-02 · Sitara Linux Training: Hands on with QT 1 Sitara Linux Training: Hands on with QT Introduction This lab is

Sitara Linux Training: Hands on with QT 20

12. Finally since we don't have a keyboard to type a command lets add a predefined command to our line EditWidget like shown below:• Double click on the line edit and add the text: date --help

13. Now run, you should see interaction with the Linux shell when you push sendCMD.

Page 21: Sitara Linux Training: Hands on with QT - Компэл · 2019-08-02 · Sitara Linux Training: Hands on with QT 1 Sitara Linux Training: Hands on with QT Introduction This lab is

Sitara Linux Training: Hands on with QT 21

LAB 4: Enhancing the project with a web viewer, soft keyboard, and StyleSheets

DescriptionIn this section we Enhance our GUI with a web browser, soft keyboard and style sheets.

Key Points• Adding a Web view.• Adding a softkeyboard.• How to adjust the look and feel

Lab Steps1. One of the first things we did in the Terminal Lab was to add a Tab widget which is a container widget. So far we

added a Linux shell terminal to Tab 1, now lets add a Web View widget to Tab 2• From the terminal.ui, click on Tab 2 and notice it is empty.

• Drag over a QWebView widget to Tab 2• Set the Layout of Tab 2 to a vertical layout

NOTEDo you recall how we did this on the Terminal Lab? On the top right, right click tabWidget -> Lay Out -> LayOut Vertically

• When complete with the above steps, it should look like the following:2. Now we can add a default URL. Since we are not connected to the internet, lets bring up matrix since it is

running on a local server.• Select the WebView widget and on the bottom right find the url property of QWebView near the bottom of

the list.• Type in: http:/ / localhost'''

Page 22: Sitara Linux Training: Hands on with QT - Компэл · 2019-08-02 · Sitara Linux Training: Hands on with QT 1 Sitara Linux Training: Hands on with QT Introduction This lab is

Sitara Linux Training: Hands on with QT 22

NOTENotice how the Webview in your ui tries to display the webpage but can't since it is not local to your host.Some people see this error and some do not.

3. Now we need to add the webkit libraries to our project.• Go to Edit mode and bring up the terminal.pro file• Add webkit as shown below

Page 23: Sitara Linux Training: Hands on with QT - Компэл · 2019-08-02 · Sitara Linux Training: Hands on with QT 1 Sitara Linux Training: Hands on with QT Introduction This lab is

Sitara Linux Training: Hands on with QT 23

4. Give it a try and run it, you should see the Matrix displayed.5. Now lets address a couple of cosmetic issues. Notice how our new GUI does not fill the entire screen.

• Change over to Edit' mode and bring up main.cpp.• Find the line w.show()

• Remove that line• type w. and notice how QT Creator will fill in all the possible options. Also notice that when you start to

type it will jump the available options with the matching text.• Select w.showFullScreen(); see screen shot.

Page 24: Sitara Linux Training: Hands on with QT - Компэл · 2019-08-02 · Sitara Linux Training: Hands on with QT 1 Sitara Linux Training: Hands on with QT Introduction This lab is

Sitara Linux Training: Hands on with QT 24

6. Now re-run and notice how it takes up the full screen.

IMPORTANTYou will need to use the Exit button on Tab1 to close this program

7. Now lets fix another issue back on Tab 1. We hard coded in a default command: date --help

• Since we did not provide a keyboard, lets add a soft keyboard.• Download a keyboard class from this location: Qt Keyboard Template wiki [5]. These instruction assume

you downloaded the tarball to the /home/sitara directory.

Page 25: Sitara Linux Training: Hands on with QT - Компэл · 2019-08-02 · Sitara Linux Training: Hands on with QT 1 Sitara Linux Training: Hands on with QT Introduction This lab is

Sitara Linux Training: Hands on with QT 25

IMPORTANTIf you are using a TI laptop or followed the host configuration steps you can find these files in the/home/sitara/sitara-training-helper-files/QT_Lab/keyboard directory and can skip these steps

• cd /home/sitara• tar -xzvf Keyboard.tar.gz

• Copy the keyboard files to your terminal project directory• cd /home/sitara/terminal/• cp -rf <keyboard extraction directory>/keyboard .

• Now lets add keyboard into our project.• Go to Edit mode and right click on terminal -> Add Existing Files as shown below.

• Navigate to the keyboard directory /home/sitara/terminal/keyboard and add all 4 files in that directory.

Page 26: Sitara Linux Training: Hands on with QT - Компэл · 2019-08-02 · Sitara Linux Training: Hands on with QT 1 Sitara Linux Training: Hands on with QT Introduction This lab is

Sitara Linux Training: Hands on with QT 26

NOTENotice how all four keyboard files are now part of the Terminal project. Click on the keyboard.ui and take alook. It is made up mainly of QPushButtons and one QLineEdit and layout controls

• Now we need to hook in the keyboard to the terminal GUI.IMPORTANTAs always you can find copy that you can copy into your project in the/home/sitara/sitara-training-helper-files/QT_Lab/lab4 directory

• Add some code to terminal.h• At the top of the file add

#include "keyboard/keyboard.h• In private slots: add

void open_keyboard_lineEdit();• In the section private: add

Keyboard *lineEditkeyboard;

Page 27: Sitara Linux Training: Hands on with QT - Компэл · 2019-08-02 · Sitara Linux Training: Hands on with QT 1 Sitara Linux Training: Hands on with QT Introduction This lab is

Sitara Linux Training: Hands on with QT 27

• Now add some code to terminal.cpp

• In the function terminal::terminal

lineEditkeyboard = new Keyboard();

connect( ui->lineEdit_commandline ,SIGNAL(selectionChanged()),this,SLOT(open_keyboard_lineEdit()));

• Also add the function below to the bottom of terminal.cpp

void terminal::open_keyboard_lineEdit()

{ QLineEdit *line = (QLineEdit *)sender(); lineEditkeyboard->setLineEdit(line);lineEditkeyboard->show();

} 8. You are now ready to run your code.

• Run and verify when you touch the line edit widget, that the keyboard pops up.IMPORTANTDepending on your screen resolution you may need to double-tap the bar at the top of the keyboard to size it tofull screen

9. Type in a linux command such as ps to list the running processes and verify that you get back the expectedresults.

10. Next lets add specific colors to the GUI components using style sheets.• Go back to your ui in the upper right corner: right click on the terminal widget -> Change styleSheet• Cut and paste from terminal sytle sheet settings at the end of this lab section to the Terminal stylesheet settings

and Apply them

Page 28: Sitara Linux Training: Hands on with QT - Компэл · 2019-08-02 · Sitara Linux Training: Hands on with QT 1 Sitara Linux Training: Hands on with QT Introduction This lab is

Sitara Linux Training: Hands on with QT 28

IMPORTANTYou can find this file in the/home/sitara/sitara-training-helper-files/QT_Lab/lab4/style_sheet_terminal.txt file

• Do the same thing for the Tab Widget by cutting and pasting from the tab style sheet settings at the end of thisLab sectionIMPORTANTYou can find this file in the /home/sitara/sitara-training-helper-files/QT_Lab/lab4/style_sheet_tab.txt file

11. voila ... TI colors - your setup should now match the look and feel of the one below:12. Run it!13. Extra investigation: Run a debug session and set break points in keyboard.cpp. Notice how the each

QPushbutton signals the keyboardHandler slot.• NOTE

If breakpoints are not working for you, verify you have created a Debug version of terminal and not a Releaseversion. Look under Projects and "Build Settings" and check Details under Build Steps.

terminal style sheet settings

QWidget {

background-color: rgb(0, 0, 0);

}

QTabWidget::pane {

position: absolute;

border: 2px solid red;

}

QTabWidget::tab-bar {

alignment: center;

}

QTabBar::tab {

color: red;

background-color: black;

border: 2px solid red;

border-radius: 0px;

padding: 4px;

margin-left: 0.25em;

margin-right: 0.25em;

}

QTabBar::tab:selected, QTabBar::tab:hover {

color: white;

background: red;

}

QPushButton {

/**font: bold 16pt;

color: white ;

Page 29: Sitara Linux Training: Hands on with QT - Компэл · 2019-08-02 · Sitara Linux Training: Hands on with QT 1 Sitara Linux Training: Hands on with QT Introduction This lab is

Sitara Linux Training: Hands on with QT 29

border-image: url(:/pushblueup.png);

background-color: transparent;

border-top: 3px transparent;

border-bottom: 3px transparent;

border-right: 10px transparent;

border-left: 10px transparent;**/

}

tab style sheet settings

QWidget{

background-color: red;

}

QTextBrowser{

background-color: black;

color: yellow;

}

QLineEdit{

background-color: white;

color: black;

}

QPushButton{

}

QWebView{

background-color: white;

}

LAB 5: Exploring Existing Demos and Examples

Key Points• Exploring existing projects in the QT SDK.• Using a SGX accelerated QT Demo

Lab Steps1. In a console window on your host:

• gedit /home/sitara/ti-sdk-<machine>-<sdkversion>/example-applications/matrix-gui-browser-2.0/main.cpp

NOTEThis is the QT application which displays matrix for all Sitara platforms. As you can see it uses a QWebViewjust like we did in the Terminal Enhancements Lab. The main differences are that you pass in the url as anargument, and all window framing was removed.

2. Now try this one using the minicom connection to your target, it may surpise some of you:

Page 30: Sitara Linux Training: Hands on with QT - Компэл · 2019-08-02 · Sitara Linux Training: Hands on with QT 1 Sitara Linux Training: Hands on with QT Introduction This lab is

Sitara Linux Training: Hands on with QT 30

• cd usr/bin/qtopia• We are now in the target Filesystem provided with Sitara SDK. Lets search for how many QT project files we

can find.• find . -name *.pro

• There are many QT project files here• find . -name *.pro | wc

• Over 300 different projects already available in the SDK.3. Lets take a look at one specific example hellogl_es2. This is an SGX accelerate QT demo. In your minicom

window do• cd /usr/bin/qtopia/examples/opengl/hellogl_es2• run this ./hellogl_es2 -qws

4. We see a black screen. This is because there are additional steps required to enable SGX acceleration.5. You can exit this application using Ctrl-Z6. Edit the file /etc/powervr.ini and add the following lines at the end of the file

[hellogl_es2]WindowSystem=libpvrQWSWSEGL.so.1

7. The final file should look like:IMPORTANTYou can find a copy of this file in the /home/sitara/sitara-training-helper-files/QT_Lab/lab5 directory[default]WindowSystem=libpvrPVR2D_FRONTWSEGL.so.1[hellogl_es2]WindowSystem=libpvrQWSWSEGL.so.1

8. Re-run hellogl_es2 again but with these additional parameters:• ./hellogl_es2 -qws -display powervr

9. You should see an SGX accelerated demo

Page 31: Sitara Linux Training: Hands on with QT - Компэл · 2019-08-02 · Sitara Linux Training: Hands on with QT 1 Sitara Linux Training: Hands on with QT Introduction This lab is

Sitara Linux Training: Hands on with QT 31

10. As mentioned there are many demos available. Some may not work due to how QT was configured when it wasbuilt.

11. Some additional demos of interest:1. /usr/bin/qtopia/demos/qtdemo -- This is a demo which lets you browse through all the demos and launch

them (It is currently not building in this release, but should be fixed in future releases)2. /usr/bin/qtopia/demos/browser -- This is the broswer demo featured in matrix.

12. Extra Excercise: Pull in one the the demos or examples into QT Creator by opening it as a project. Build it andrun it on the target.

NOTEYou may need need to do some project setup to make sure you will run on the target

References[1] https:/ / estore. ti. com/ TMDSSK3358-AM335x-Starter-Kit-P3110. aspx[2] http:/ / processors. wiki. ti. com/ index. php/ Sitara_Linux_Training:_Linux_Host_Configuration[3] http:/ / www. ti. com/ tool/ linuxezsdk-sitara[4] http:/ / get. qt. nokia. com/ qtcreator/ qt-creator-linux-x86-opensource-2. 4. 1. bin[5] http:/ / processors. wiki. ti. com/ index. php/ Qt_Keyboard_Template

Page 32: Sitara Linux Training: Hands on with QT - Компэл · 2019-08-02 · Sitara Linux Training: Hands on with QT 1 Sitara Linux Training: Hands on with QT Introduction This lab is

Article Sources and Contributors 32

Article Sources and ContributorsSitara Linux Training: Hands on with QT  Source: http://processors.wiki.ti.com/index.php?oldid=120044  Contributors: Cem8101, Fcooper, Gary, Jefflance01, Kevinsc

Image Sources, Licenses and ContributorsImage:TIBanner.png  Source: http://processors.wiki.ti.com/index.php?title=File:TIBanner.png  License: unknown  Contributors: NsnehaprabhaImage:Sitara-linux-training-cross-tools.png  Source: http://processors.wiki.ti.com/index.php?title=File:Sitara-linux-training-cross-tools.png  License: unknown  Contributors: Cem8101Image:Sitara Linux QT library listings.png  Source: http://processors.wiki.ti.com/index.php?title=File:Sitara_Linux_QT_library_listings.png  License: unknown  Contributors: Jefflance01Image:Sitara-Qt Creator.png  Source: http://processors.wiki.ti.com/index.php?title=File:Sitara-Qt_Creator.png  License: unknown  Contributors: Jefflance01Image:Sitara-BuildAndRun.png  Source: http://processors.wiki.ti.com/index.php?title=File:Sitara-BuildAndRun.png  License: unknown  Contributors: Jefflance01Image:Sitara-compilerAndDebugger.png  Source: http://processors.wiki.ti.com/index.php?title=File:Sitara-compilerAndDebugger.png  License: unknown  Contributors: Jefflance01Image:Sitara next finish.png  Source: http://processors.wiki.ti.com/index.php?title=File:Sitara_next_finish.png  License: unknown  Contributors: Jefflance01Image:Sitara target test.png  Source: http://processors.wiki.ti.com/index.php?title=File:Sitara_target_test.png  License: unknown  Contributors: Jefflance01Image:Sitara settingup target.png  Source: http://processors.wiki.ti.com/index.php?title=File:Sitara_settingup_target.png  License: unknown  Contributors: Jefflance01Image:Sitara successful deploy.png  Source: http://processors.wiki.ti.com/index.php?title=File:Sitara_successful_deploy.png  License: unknown  Contributors: Jefflance01Image:Sitara target setup.png  Source: http://processors.wiki.ti.com/index.php?title=File:Sitara_target_setup.png  License: unknown  Contributors: Jefflance01Image:Sitara-terminal-pro.png  Source: http://processors.wiki.ti.com/index.php?title=File:Sitara-terminal-pro.png  License: unknown  Contributors: Jefflance01Image:Sitara hello world UI.png  Source: http://processors.wiki.ti.com/index.php?title=File:Sitara_hello_world_UI.png  License: unknown  Contributors: Jefflance01Image:Sitara Build settings.png  Source: http://processors.wiki.ti.com/index.php?title=File:Sitara_Build_settings.png  License: unknown  Contributors: Jefflance01Image:Sitara deploy remote.png  Source: http://processors.wiki.ti.com/index.php?title=File:Sitara_deploy_remote.png  License: unknown  Contributors: Jefflance01Image:Sitara add target loc.png  Source: http://processors.wiki.ti.com/index.php?title=File:Sitara_add_target_loc.png  License: unknown  Contributors: Jefflance01Image:Sitara tab widget.png  Source: http://processors.wiki.ti.com/index.php?title=File:Sitara_tab_widget.png  License: unknown  Contributors: Jefflance01Image:Sitara layout vertically.png  Source: http://processors.wiki.ti.com/index.php?title=File:Sitara_layout_vertically.png  License: unknown  Contributors: Jefflance01Image:Sitara adjust widths.png  Source: http://processors.wiki.ti.com/index.php?title=File:Sitara_adjust_widths.png  License: unknown  Contributors: Jefflance01Image:Sitara pushbutton.png  Source: http://processors.wiki.ti.com/index.php?title=File:Sitara_pushbutton.png  License: unknown  Contributors: Jefflance01Image:Sitara SendCMD code.png  Source: http://processors.wiki.ti.com/index.php?title=File:Sitara_SendCMD_code.png  License: unknown  Contributors: Jefflance01Image:Sitara add command.png  Source: http://processors.wiki.ti.com/index.php?title=File:Sitara_add_command.png  License: unknown  Contributors: Jefflance01Image:Sitara default url.png  Source: http://processors.wiki.ti.com/index.php?title=File:Sitara_default_url.png  License: unknown  Contributors: Jefflance01Image:Sitara webkit.png  Source: http://processors.wiki.ti.com/index.php?title=File:Sitara_webkit.png  License: unknown  Contributors: Jefflance01Image:Sitara fullscreen.png  Source: http://processors.wiki.ti.com/index.php?title=File:Sitara_fullscreen.png  License: unknown  Contributors: Jefflance01Image:Sitara matrix.PNG  Source: http://processors.wiki.ti.com/index.php?title=File:Sitara_matrix.PNG  License: unknown  Contributors: Jefflance01Image:Sitara addexisting.png  Source: http://processors.wiki.ti.com/index.php?title=File:Sitara_addexisting.png  License: unknown  Contributors: Jefflance01Image:Sitara addkeyboard.png  Source: http://processors.wiki.ti.com/index.php?title=File:Sitara_addkeyboard.png  License: unknown  Contributors: Jefflance01Image:Sitara terminal h.png  Source: http://processors.wiki.ti.com/index.php?title=File:Sitara_terminal_h.png  License: unknown  Contributors: Jefflance01Image:Hellogl.PNG  Source: http://processors.wiki.ti.com/index.php?title=File:Hellogl.PNG  License: unknown  Contributors: Jefflance01

LicenseTHE WORK (AS DEFINED BELOW) IS PROVIDED UNDER THE TERMS OF THIS CREATIVE COMMONS PUBLIC LICENSE ("CCPL" OR "LICENSE"). THE WORK IS PROTECTED BY COPYRIGHT AND/OR OTHERAPPLICABLE LAW. ANY USE OF THE WORK OTHER THAN AS AUTHORIZED UNDER THIS LICENSE OR COPYRIGHT LAW IS PROHIBITED.BY EXERCISING ANY RIGHTS TO THE WORK PROVIDED HERE, YOU ACCEPT AND AGREE TO BE BOUND BY THE TERMS OF THIS LICENSE. TO THE EXTENT THIS LICENSE MAY BE CONSIDERED TO BEA CONTRACT, THE LICENSOR GRANTS YOU THE RIGHTS CONTAINED HERE IN CONSIDERATION OF YOUR ACCEPTANCE OF SUCH TERMS AND CONDITIONS.License1. Definitionsa. "Adaptation" means a work based upon the Work, or upon the Work and other pre-existing works, such as a translation, adaptation, derivative work, arrangement of music or other alterations of a literary or artistic work, or

phonogram or performance and includes cinematographic adaptations or any other form in which the Work may be recast, transformed, or adapted including in any form recognizably derived from the original, except that a workthat constitutes a Collection will not be considered an Adaptation for the purpose of this License. For the avoidance of doubt, where the Work is a musical work, performance or phonogram, the synchronization of the Work intimed-relation with a moving image ("synching") will be considered an Adaptation for the purpose of this License.

b. "Collection" means a collection of literary or artistic works, such as encyclopedias and anthologies, or performances, phonograms or broadcasts, or other works or subject matter other than works listed in Section 1(f) below,which, by reason of the selection and arrangement of their contents, constitute intellectual creations, in which the Work is included in its entirety in unmodified form along with one or more other contributions, each constitutingseparate and independent works in themselves, which together are assembled into a collective whole. A work that constitutes a Collection will not be considered an Adaptation (as defined below) for the purposes of this License.

c. "Creative Commons Compatible License" means a license that is listed at http:/ / creativecommons. org/ compatiblelicenses that has been approved by Creative Commons as being essentially equivalent to this License,including, at a minimum, because that license: (i) contains terms that have the same purpose, meaning and effect as the License Elements of this License; and, (ii) explicitly permits the relicensing of adaptations of works madeavailable under that license under this License or a Creative Commons jurisdiction license with the same License Elements as this License.

d. "Distribute" means to make available to the public the original and copies of the Work or Adaptation, as appropriate, through sale or other transfer of ownership.e. "License Elements" means the following high-level license attributes as selected by Licensor and indicated in the title of this License: Attribution, ShareAlike.f. "Licensor" means the individual, individuals, entity or entities that offer(s) the Work under the terms of this License.g. "Original Author" means, in the case of a literary or artistic work, the individual, individuals, entity or entities who created the Work or if no individual or entity can be identified, the publisher; and in addition (i) in the case of a

performance the actors, singers, musicians, dancers, and other persons who act, sing, deliver, declaim, play in, interpret or otherwise perform literary or artistic works or expressions of folklore; (ii) in the case of a phonogram theproducer being the person or legal entity who first fixes the sounds of a performance or other sounds; and, (iii) in the case of broadcasts, the organization that transmits the broadcast.

h. "Work" means the literary and/or artistic work offered under the terms of this License including without limitation any production in the literary, scientific and artistic domain, whatever may be the mode or form of its expressionincluding digital form, such as a book, pamphlet and other writing; a lecture, address, sermon or other work of the same nature; a dramatic or dramatico-musical work; a choreographic work or entertainment in dumb show; amusical composition with or without words; a cinematographic work to which are assimilated works expressed by a process analogous to cinematography; a work of drawing, painting, architecture, sculpture, engraving orlithography; a photographic work to which are assimilated works expressed by a process analogous to photography; a work of applied art; an illustration, map, plan, sketch or three-dimensional work relative to geography,topography, architecture or science; a performance; a broadcast; a phonogram; a compilation of data to the extent it is protected as a copyrightable work; or a work performed by a variety or circus performer to the extent it is nototherwise considered a literary or artistic work.

i. "You" means an individual or entity exercising rights under this License who has not previously violated the terms of this License with respect to the Work, or who has received express permission from the Licensor to exerciserights under this License despite a previous violation.

j. "Publicly Perform" means to perform public recitations of the Work and to communicate to the public those public recitations, by any means or process, including by wire or wireless means or public digital performances; tomake available to the public Works in such a way that members of the public may access these Works from a place and at a place individually chosen by them; to perform the Work to the public by any means or process and thecommunication to the public of the performances of the Work, including by public digital performance; to broadcast and rebroadcast the Work by any means including signs, sounds or images.

k. "Reproduce" means to make copies of the Work by any means including without limitation by sound or visual recordings and the right of fixation and reproducing fixations of the Work, including storage of a protectedperformance or phonogram in digital form or other electronic medium.

2. Fair Dealing RightsNothing in this License is intended to reduce, limit, or restrict any uses free from copyright or rights arising from limitations or exceptions that are provided for in connection with the copyright protection under copyright law or otherapplicable laws.3. License GrantSubject to the terms and conditions of this License, Licensor hereby grants You a worldwide, royalty-free, non-exclusive, perpetual (for the duration of the applicable copyright) license to exercise the rights in the Work as statedbelow:a. to Reproduce the Work, to incorporate the Work into one or more Collections, and to Reproduce the Work as incorporated in the Collections;b. to create and Reproduce Adaptations provided that any such Adaptation, including any translation in any medium, takes reasonable steps to clearly label, demarcate or otherwise identify that changes were made to the original

Work. For example, a translation could be marked "The original work was translated from English to Spanish," or a modification could indicate "The original work has been modified.";c. to Distribute and Publicly Perform the Work including as incorporated in Collections; and,d. to Distribute and Publicly Perform Adaptations.e. For the avoidance of doubt:

Page 33: Sitara Linux Training: Hands on with QT - Компэл · 2019-08-02 · Sitara Linux Training: Hands on with QT 1 Sitara Linux Training: Hands on with QT Introduction This lab is

License 33

i. Non-waivable Compulsory License Schemes. In those jurisdictions in which the right to collect royalties through any statutory or compulsory licensing scheme cannot be waived, the Licensor reserves the exclusive rightto collect such royalties for any exercise by You of the rights granted under this License;

ii. Waivable Compulsory License Schemes. In those jurisdictions in which the right to collect royalties through any statutory or compulsory licensing scheme can be waived, the Licensor waives the exclusive right to collectsuch royalties for any exercise by You of the rights granted under this License; and,

iii. Voluntary License Schemes. The Licensor waives the right to collect royalties, whether individually or, in the event that the Licensor is a member of a collecting society that administers voluntary licensing schemes, viathat society, from any exercise by You of the rights granted under this License.

The above rights may be exercised in all media and formats whether now known or hereafter devised. The above rights include the right to make such modifications as are technically necessary to exercise the rights in other media andformats. Subject to Section 8(f), all rights not expressly granted by Licensor are hereby reserved.4. RestrictionsThe license granted in Section 3 above is expressly made subject to and limited by the following restrictions:a. You may Distribute or Publicly Perform the Work only under the terms of this License. You must include a copy of, or the Uniform Resource Identifier (URI) for, this License with every copy of the Work You Distribute or

Publicly Perform. You may not offer or impose any terms on the Work that restrict the terms of this License or the ability of the recipient of the Work to exercise the rights granted to that recipient under the terms of the License.You may not sublicense the Work. You must keep intact all notices that refer to this License and to the disclaimer of warranties with every copy of the Work You Distribute or Publicly Perform. When You Distribute or PubliclyPerform the Work, You may not impose any effective technological measures on the Work that restrict the ability of a recipient of the Work from You to exercise the rights granted to that recipient under the terms of the License.This Section 4(a) applies to the Work as incorporated in a Collection, but this does not require the Collection apart from the Work itself to be made subject to the terms of this License. If You create a Collection, upon notice fromany Licensor You must, to the extent practicable, remove from the Collection any credit as required by Section 4(c), as requested. If You create an Adaptation, upon notice from any Licensor You must, to the extent practicable,remove from the Adaptation any credit as required by Section 4(c), as requested.

b. You may Distribute or Publicly Perform an Adaptation only under the terms of: (i) this License; (ii) a later version of this License with the same License Elements as this License; (iii) a Creative Commons jurisdiction license(either this or a later license version) that contains the same License Elements as this License (e.g., Attribution-ShareAlike 3.0 US)); (iv) a Creative Commons Compatible License. If you license the Adaptation under one of thelicenses mentioned in (iv), you must comply with the terms of that license. If you license the Adaptation under the terms of any of the licenses mentioned in (i), (ii) or (iii) (the "Applicable License"), you must comply with theterms of the Applicable License generally and the following provisions: (I) You must include a copy of, or the URI for, the Applicable License with every copy of each Adaptation You Distribute or Publicly Perform; (II) Youmay not offer or impose any terms on the Adaptation that restrict the terms of the Applicable License or the ability of the recipient of the Adaptation to exercise the rights granted to that recipient under the terms of the ApplicableLicense; (III) You must keep intact all notices that refer to the Applicable License and to the disclaimer of warranties with every copy of the Work as included in the Adaptation You Distribute or Publicly Perform; (IV) whenYou Distribute or Publicly Perform the Adaptation, You may not impose any effective technological measures on the Adaptation that restrict the ability of a recipient of the Adaptation from You to exercise the rights granted tothat recipient under the terms of the Applicable License. This Section 4(b) applies to the Adaptation as incorporated in a Collection, but this does not require the Collection apart from the Adaptation itself to be made subject tothe terms of the Applicable License.

c. If You Distribute, or Publicly Perform the Work or any Adaptations or Collections, You must, unless a request has been made pursuant to Section 4(a), keep intact all copyright notices for the Work and provide, reasonable to themedium or means You are utilizing: (i) the name of the Original Author (or pseudonym, if applicable) if supplied, and/or if the Original Author and/or Licensor designate another party or parties (e.g., a sponsor institute,publishing entity, journal) for attribution ("Attribution Parties") in Licensor's copyright notice, terms of service or by other reasonable means, the name of such party or parties; (ii) the title of the Work if supplied; (iii) to theextent reasonably practicable, the URI, if any, that Licensor specifies to be associated with the Work, unless such URI does not refer to the copyright notice or licensing information for the Work; and (iv) , consistent withSsection 3(b), in the case of an Adaptation, a credit identifying the use of the Work in the Adaptation (e.g., "French translation of the Work by Original Author," or "Screenplay based on original Work by Original Author"). Thecredit required by this Section 4(c) may be implemented in any reasonable manner; provided, however, that in the case of a Adaptation or Collection, at a minimum such credit will appear, if a credit for all contributing authors ofthe Adaptation or Collection appears, then as part of these credits and in a manner at least as prominent as the credits for the other contributing authors. For the avoidance of doubt, You may only use the credit required by thisSection for the purpose of attribution in the manner set out above and, by exercising Your rights under this License, You may not implicitly or explicitly assert or imply any connection with, sponsorship or endorsement by theOriginal Author, Licensor and/or Attribution Parties, as appropriate, of You or Your use of the Work, without the separate, express prior written permission of the Original Author, Licensor and/or Attribution Parties.

d. Except as otherwise agreed in writing by the Licensor or as may be otherwise permitted by applicable law, if You Reproduce, Distribute or Publicly Perform the Work either by itself or as part of any Adaptations or Collections,You must not distort, mutilate, modify or take other derogatory action in relation to the Work which would be prejudicial to the Original Author's honor or reputation. Licensor agrees that in those jurisdictions (e.g. Japan), inwhich any exercise of the right granted in Section 3(b) of this License (the right to make Adaptations) would be deemed to be a distortion, mutilation, modification or other derogatory action prejudicial to the Original Author'shonor and reputation, the Licensor will waive or not assert, as appropriate, this Section, to the fullest extent permitted by the applicable national law, to enable You to reasonably exercise Your right under Section 3(b) of thisLicense (right to make Adaptations) but not otherwise.

5. Representations, Warranties and DisclaimerUNLESS OTHERWISE MUTUALLY AGREED TO BY THE PARTIES IN WRITING, LICENSOR OFFERS THE WORK AS-IS AND MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND CONCERNINGTHE WORK, EXPRESS, IMPLIED, STATUTORY OR OTHERWISE, INCLUDING, WITHOUT LIMITATION, WARRANTIES OF TITLE, MERCHANTIBILITY, FITNESS FOR A PARTICULAR PURPOSE,NONINFRINGEMENT, OR THE ABSENCE OF LATENT OR OTHER DEFECTS, ACCURACY, OR THE PRESENCE OF ABSENCE OF ERRORS, WHETHER OR NOT DISCOVERABLE. SOME JURISDICTIONS DO NOTALLOW THE EXCLUSION OF IMPLIED WARRANTIES, SO SUCH EXCLUSION MAY NOT APPLY TO YOU.6. Limitation on LiabilityEXCEPT TO THE EXTENT REQUIRED BY APPLICABLE LAW, IN NO EVENT WILL LICENSOR BE LIABLE TO YOU ON ANY LEGAL THEORY FOR ANY SPECIAL, INCIDENTAL, CONSEQUENTIAL, PUNITIVEOR EXEMPLARY DAMAGES ARISING OUT OF THIS LICENSE OR THE USE OF THE WORK, EVEN IF LICENSOR HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.7. Terminationa. This License and the rights granted hereunder will terminate automatically upon any breach by You of the terms of this License. Individuals or entities who have received Adaptations or Collections from You under this License,

however, will not have their licenses terminated provided such individuals or entities remain in full compliance with those licenses. Sections 1, 2, 5, 6, 7, and 8 will survive any termination of this License.b. Subject to the above terms and conditions, the license granted here is perpetual (for the duration of the applicable copyright in the Work). Notwithstanding the above, Licensor reserves the right to release the Work under different

license terms or to stop distributing the Work at any time; provided, however that any such election will not serve to withdraw this License (or any other license that has been, or is required to be, granted under the terms of thisLicense), and this License will continue in full force and effect unless terminated as stated above.

8. Miscellaneousa. Each time You Distribute or Publicly Perform the Work or a Collection, the Licensor offers to the recipient a license to the Work on the same terms and conditions as the license granted to You under this License.b. Each time You Distribute or Publicly Perform an Adaptation, Licensor offers to the recipient a license to the original Work on the same terms and conditions as the license granted to You under this License.c. If any provision of this License is invalid or unenforceable under applicable law, it shall not affect the validity or enforceability of the remainder of the terms of this License, and without further action by the parties to this

agreement, such provision shall be reformed to the minimum extent necessary to make such provision valid and enforceable.d. No term or provision of this License shall be deemed waived and no breach consented to unless such waiver or consent shall be in writing and signed by the party to be charged with such waiver or consent.e. This License constitutes the entire agreement between the parties with respect to the Work licensed here. There are no understandings, agreements or representations with respect to the Work not specified here. Licensor shall not

be bound by any additional provisions that may appear in any communication from You. This License may not be modified without the mutual written agreement of the Licensor and You.f. The rights granted under, and the subject matter referenced, in this License were drafted utilizing the terminology of the Berne Convention for the Protection of Literary and Artistic Works (as amended on September 28, 1979),

the Rome Convention of 1961, the WIPO Copyright Treaty of 1996, the WIPO Performances and Phonograms Treaty of 1996 and the Universal Copyright Convention (as revised on July 24, 1971). These rights and subjectmatter take effect in the relevant jurisdiction in which the License terms are sought to be enforced according to the corresponding provisions of the implementation of those treaty provisions in the applicable national law. If thestandard suite of rights granted under applicable copyright law includes additional rights not granted under this License, such additional rights are deemed to be included in the License; this License is not intended to restrict thelicense of any rights under applicable law.