These instructions were tested on Ubuntu 12.04, Ubuntu 12.10 both 32-bit and 64-bit.
First off we need to install some dependencies. Install these even if you already have Qt5 installed:
sudo apt-get install build-essential libgtk2.0-dev libgl1-mesa-dev
If you haven't already, download and install the QtSDK from http://qt-project.org/downloads.
For Ubuntu 64-bit run:
cd ~
wget http://releases.qt-project.org/qt5/5.0.0/qt-linux-opensource-5.0.0-x86_64-offline.run
mv qt-linux-opensource-5.0.0-x86_64-offline.run qt5-installer.run
For Ubuntu 32-bit run:
cd ~
wget http://releases.qt-project.org/qt5/5.0.0/qt-linux-opensource-5.0.0-x86-offline.run
mv qt-linux-opensource-5.0.0-x86-offline.run qt5-installer.run
Then make it executable:
chmod +x qt5-installer.run
Now run it as root in order to install it to /opt:
sudo ./qt5-installer.run
Follow the prompts and, when asked where to install, select /opt/QtSDK.
From now on I will assume that you have it installed to that location, if you already had the Qt installed to a different location, adapt the steps in order to reflect your installation.
After installation I suggest you delete the QtCreator configuration folder as the permissions are wrong. QtCreator will recreate them when restarted.
cd ~/.config
sudo rm -rf QtProject
Now for the Qt Ubuntu Components, download the source file and unpack it:
wget https://launchpad.net/~ui-toolkit/+archive/ppa/+files/qt-components-ubuntu_0.1.24%7Equantal1.tar.gz
tar -zxvf qt-components-ubuntu_0.1.24~quantal1.tar.gz
Now in order to compile and install the components we need to create some sim-links.
For Ubuntu 64-bit run:
sudo ln -s /opt/QtSDK/5.0.0/gcc_x64 /opt/qt5
For Ubuntu 32-bit run:
sudo ln -s /opt/QtSDK/5.0.0/gcc /opt/qt5
One more thing before we compile and install, we need to change two environment variables, PATH and QML_IMPORT_PATH:
export PATH=$PATH:/opt/qt5/bin
export QML_IMPORT_PATH=/opt/qt5/imports
echo 'export PATH=$PATH:/opt/qt5/bin' >> ~/.bashrc
echo 'export QML_IMPORT_PATH=/opt/qt5/imports' >> ~/.bashrc
Now we need generate a Makefile an build the Qt Ubuntu Components:
cd ~/trunk
qmake ubuntu-sdk.pro
make
sudo make install
If everything went OK, the the components should be built and installed, now we need to try it out to make sure everything went alright. I suggest you log out and the back in before doing the next steps.
- Open QtCreator, go to Tools -> Options, select the External Tools
tab.
- For Qt Quick 1 Preview (qmlviewer), in the Executable field write: /opt/qt5/bin/qmlviewer
- For Qt Quick 2 Preview (qmlscene), in the Executable field write: /opt/qt5/bin/qmlscene.
- Click Apply and close the Options window.
Everything should be working now, one thing to keep in mind is that in order to successfully execute a QML Ubuntu Phone Application, in the .qmlproject file you need to uncomment importPaths and add "/opt/qt5/imports" to it like so:
Project {
...
/* List of plugin directories passed to QML runtime */
importPaths: [ "/opt/qt5/imports" ]
...
}
That's about it. For any questions comment and I'll try to get back to you. Have Fun!