Começando a trabalhar com QtCreator e QGIS¶
QtCreator is a newish IDE from the makers of the Qt library. With QtCreator you can build any C++ project, but it’s really optimised for people working on Qt(4) based applications (including mobile apps). Everything I describe below assumes you are running Ubuntu 11.04 ‘Natty’.
Essa parte é fácil:
sudo apt-get install qtcreator qtcreator-doc
Após a instalação você deve encontrá-lo no menu do gnome
I’m assuming you have already got a local QGIS clone containing the source code, and have installed all needed build dependencies etc. There are detailed instructions for git access and dependency installation.
On my system I have checked out the code into
$HOME/dev/cpp/QGIS and the
rest of the article is written assuming that, you should update these paths as
appropriate for your local system.
Ao abrir o QtCreator:
Arquivo -> Abrir Arquivo ou Projeto*
Depois use o diálogo de seleção de arquivo resultante para procurar e abrir este arquivo:
Next you will be prompted for a build location. I create a specific build dir for QtCreator to work in under:
Its probably a good idea to create separate build directories for different branches if you can afford the disk space.
Next you will be asked if you have any CMake build options to pass to CMake. We will tell CMake that we want a debug build by adding this option:
That’s the basics of it. When you complete the Wizard, QtCreator will start scanning the source tree for autocompletion support and do some other housekeeping stuff in the background. We want to tweak a few things before we start to build though.
Click on the ‘Projects’ icon on the left of the QtCreator window.
Select the build settings tab (normally active by default).
We now want to add a custom process step. Why? Because QGIS can currently only run from an install directory, not its build directory, so we need to ensure that it is installed whenever we build it. Under ‘Build Steps’, click on the ‘Add BuildStep’ combo button and choose ‘Custom Process Step’.
Agora vamos definir os seguintes detalhes:
Enable custom process step: [yes]
Working directory: $HOME/dev/cpp/QGIS/build-master-qtcreator
Argumentos de comando: install
You are almost ready to build. Just one note: QtCreator will need write
permissions on the install prefix. By default (which I am using here) QGIS is
going to get installed to
/usr/local/. For my purposes on my development
machine, I just gave myself write permissions to the /usr/local directory.
To start the build, click that big hammer icon on the bottom left of the window.
As mentioned above, we cannot run QGIS from directly in the build directly, so
we need to create a custom run target to tell QtCreator to run QGIS from the
install dir (in my case
/usr/local/). To do that, return to the projects
Now select the ‘Run Settings’ tab
We need to update the default run settings from using the ‘qgis’ run configuration to using a custom one.
Do do that, click the ‘Add v’ combo button next to the Run configuration combo and choose ‘Custom Executable’ from the top of the list.
Now in the properties area set the following details:
Working directory: $HOME
Run in terminal: [no]
Debugger: C++ [yes]
Then click the ‘Rename’ button and give your custom executable a meaningful name e.g. ‘Installed QGIS’