Setting up a Qt Creator project including access to QGIS API



  • I am an experienced Java developer but a C++, Qt newbie. I have a specific need to develop a desktop application that produces graphics type output as well as displaying imbedded maps. It looks like Qt and QGIS API are exactly what I need to get this going.

    I have been playing around with Qt Creator and generated several of the tutorials without too many problems. Now I am trying my first Qt project that incorporates the QGIS api. I am really stuck. I can't figure out where the libraries are that contains the QGIS modules or how to configure the Creator project properly.

    There are some good examples of code that shows how to code with QGIS classes. But I can't find anything that explains how to set the project up. Could someone please help guide me through setting up a project in Qt Creator that will allow me to incorporate the QGIS modules? I have been searching everywhere. Google can be a strange beast. Sometimes you find what you need on the first search. Other times it just never happens.

    Thanks


  • Moderators

    welcome to devnet

    Are you expecting that QGIS is part of Qt distribution?

    It is not. You probably can download QGIS from "here.":http://www.qgis.org/ You may use Qt creator later on as your IDE.



  • I've never used qgis, but most probably you need the right libraries (import and dll) built for your compiler toolset. There is an installer for windows on this webpage koahnig mentioned that ships libs as well. But I do not know if they fit your needs. So you should be able to manage building the qgis from source.

    For my own information I grabbed me the qgis-1.8.0.tar.bz2 from the "download setion":http://hub.qgis.org/projects/quantum-gis/wiki/Download#61-Source-Code. Inside you will find the "INSTALL" File where the you'll find the section 4. Building on Windows. For building inside the Qt SDK environment see chapter 4.2.2. Qt.

    I hope my comments help you to figure out the next steps. Once you have the libs ready for linking to your application, you are a few steps ahead of setting up a qt.pro projectfile.

    On which os host are you building?



  • Thanks for your responses guys. I do understand that QGIS is not part of the Qt distribution. In truth all I am trying to get is those libraries that will provide the QGIS capabilities. The biggest problem I am having is that most of you folks live in the Linux world and I can't find any meaningful instructions for Windows. For example, on the QGIS instructions it says to download from GIT. It gives a URL that starts with git://github.org/. . . . . . but it never gives a specific instruction on how to actually use the GIT command to download QGIS. So since I have never used GIT before I have no idea where to start. But I was able to download QGIS using the GITHub website. Then it tells how to build the QGIS project using CMAKE but I get dozens of errors. So there are no clear instructions on how to build the right libraries and DLLs in Windows. The author has assumed that a Windows developer knows and understands all the supporting tools that we never use on Windows.

    I realize that most Linux developers think that Windows developers are second class IT folks and like to ridicule us. But there are times we just don't have the luxury to decide on our own what platform we will use.

    I have a very specific application that I MUST develop on a specialized box that will have Windows imbedded as the platform. Qt and QGIS can provide the perfect solution for this. However I can tell it is going to take enormous effort just to figure out how to take instructions for Linux that everyone takes for granted and make it work on Windows. I can develop the code. I just have to figure out how to make the tools work.

    I'm sorry if I sound so frustrated. But it's very difficult to get instructions for Windows for these sorts of tools that actually work. It becomes a quagmire of guesses, errors and Google searches. You post questions on forums and all you get is "Use Linux!".

    Qt Creator wants to use CMAKE to build the QGIS project. So I downloaded the Windows version of CMAKE. When Qt Creator attempted to do the build I have received at least 15 different failures. From something about having the GNU Shell in the path to various exe files not found to invalid separators in configuration files.

    Yes, I need the correct libraries to put QGIS in my Qt project. That's what got this all started. I still have not found any documentation that lists the QGIS libraries and what is in them. Maybe this is a reflection of my lack of experience in C++. I am used to Java and it's jar files. I'll get this figured out but it sure won't be easy.

    This is going to be a 6 to 9 month project but I only have about 2 weeks to show proof of concept. Spending most of that time just figuring out the environment will spell certain failure.

    I hope I haven't offended anyone who might otherwise help. Anyone who has some ideas to share as to how I can get past this huge obstacle is certainly encouraged to join in.

    Thanks



  • bq. For my own information I grabbed me the qgis-1.8.0.tar.bz2 from the download setion [hub.qgis.org]. Inside you

    Have a look at this link. There you will find a tarfile (you probably found already), that you can unzip with 7zip. If you are running on windows we can have a try on building QGIS on windows. We will have a try. No more in the first step, so don't feel embarrassed. There are more than one windows developer undercover, as you might think ;-)

    bq. But I was able to download QGIS using the GITHub website. Then it tells how to build the QGIS project using CMAKE but I get dozens of errors. So there are no clear instructions on how to build the right libraries and DLLs in Windows.

    Did you install the msys environment or the QtSDK as well? The INSTALL file in the tar-archive contains some helpful comments you should read and try out. There is no automated click-compile-and-ready button, you have to spend some time to figure out how it works.



  • [quote author="franku" date="1342288048"]bq. For my own information I grabbed me the qgis-1.8.0.tar.bz2 from the download setion [hub.qgis.org]. Inside you

    No more in the first step, so don't feel embarrassed. There are more than one windows developer undercover, as you might think ;-)

    [/quote]

    I am not the least bit embarrassed. I do not feel inferior because I don't understand something. I am a solutions architect directed to develop an application on a Windows platform. I willing help others with areas in my expertise without assuming they are embarrassed when asking questions.

    [quote author="franku" date="1342288048"]
    bq. But I was able to download QGIS using the GITHub website. Then it tells how to build the QGIS project using CMAKE but I get dozens of errors. So there are no clear instructions on how to build the right libraries and DLLs in Windows.

    Did you install the msys environment or the QtSDK as well? The INSTALL file in the tar-archive contains some helpful comments you should read and try out. There is no automated click-compile-and-ready button, you have to spend some time to figure out how it works.
    [/quote]

    That is the reason I was asking questions. The entire reason for having Forums like this is to provide information so every single person trying to do this doesn't have to go through the same pain and agony.

    I have installed QGIS-final-1.8.0.2 Windows binary. I was also able to download the full GIT archive of QGIS v1.8.0.2 that includes the source. I have the full QtSDK installed. When I tried to follow a tutorial for developing a Qt Application that uses the QGIS libraries I couldn't determine where the appropriate libraries are and the tutorial did not identify them. So I started my search of those libraries with no success. Surely somewhere there is a set of QGIS binaries for Windows that include the appropriate libraries to use the API in a Qt project. Why force every single developer to generate those libraries from the source? You may consider it a fun exercise. I just need to make progress on this project or find a different set of tools.



  • You are very welcome to ask questions. If you are looking for more definite answers on building/using QGis you may want to ask on some other mailing list: "QGis Mailing List":http://qgis.org/community/mailing-lists.html.

    bq. Why force every single developer to generate those libraries from the source?

    Sometimes this is the open source way to go. You installed some windows binaries package a team of developers has provided without any charge. If you want to use their binaries with a toolset, you have to figure out, what toolset they are for. Maybe you will get further with VisualStudio. But then you will have some issues with the opensource package of Qt.

    bq. From INSTALL-file: 4.2. Building using MinGW

    Note: This section might be outdated as nowadays Visual C++ is use to build the "official" packages.

    As said above, you may want to ask at the QGIS community on how to work with their code and libraries. To speak for myself, always feel free to come back and ask precise questions. You are very welcome.



  • After a ton of searching and days trying to work with out of date "how to" guides I finally found a set of instructions that actually work. It was still a battle of trial and error but this guide was 95% correct. It came off the QGIS website, but it was still difficult to find. The URL is http://www.qgis.org/api/INSTALL.html#toc14. (Pretty obvious at this point but I Googled this issue for hours.) It gives a pretty fair explanation of how to build QGIS using Visual Studio 2008 Express. There are still some little tidbits of information left out. But you can find an explanation of what is wrong with it at "osgeo-org on nabble":http://osgeo-org.1560.n6.nabble.com/build-qgis-in-Windows-missing-GEOS-and-PROJ-4-td4952935.html. When you get to cmake-gui your first attempt at building the project will fail. It is then that you will discover what the errors are and the second link above gives the answers.

    I haven't tried using the new libraries in a Qt project yet but I am confident they will work. I had so much garbage on my machine after attempting to follow 4 or 5 different guides that were out of date and basically inaccurate. Before starting this install I removed everything including Qt and started again from scratch.

    I do appreciate the feedback and apologize for the frustrated comments.



  • Hi KyJavaGee, well done. Your work appears to be good research work.

    However, please note, if you want to use Qt opensource the Qt-VisualStudio Plugin does not work with the express editions of VS. In addition, if you want to use the libs of QGIS you've now built with VS2008 then you have to make the right import libraries for MinGW gcc linker as well.

    Please aks others if there was a way to build Qt opensource with VS. I've never used it. Maybe someone in the forum knows.



  • Thanks for your reply. I have successfully built QGis using VS Express. I'm not trying to use the plugin. I can't afford to pay the license fee for regular VS. I am trying to use Qt Creator for my project work. Now my challenge is configuring Qt Creator to find and use the QGis libraries.

    Since I am a Java developer and haven't developed in C++ for 15 years it is a real challenge just setting up the environment properly. Many of the posts that should help in this area do not state whether that solution is for Linux or Windows. So I've been busting my buns trying to find out how to generate ".a" files just to find out that is a Linux concept. When I built the Windows version of QGis it should have build .lib files that properly point to the DLLs. But evidently they don't.

    I don't know if I built the QGis improperly (or installed it wrong) or if I haven't got Qt Creator configured improperly. All I know is that Qt Creator finds no problems with syntax on my first Qt/QGis sample program. But it fails at run time not being able to find all the correct classes. So Qt Creator is obviously not finding all the proper DLLs.

    I'm going to go back and try to recreate the Qt project and make sure I didn't miss something. I think I am very, very close. I need be able to show my partners that this is a viable solution this week.



  • If you don't want to buy the VS and mix work with QtCreator using the opensource version of Qt, this contains a distribution of MinGW. MinGW is a gnu compiler/linker toolchain that needs import libraries usually built with a .a fileextension. If you build the QGis with VS then the import libs will have a .lib extension. In my experience they cannot be used with MinGW, as already mentioned above. If you want to use the dlls anyway, then you can derive the import libs for the gnu toolchain with pexports and dlltool. There are some howtos in the web you can follow. However, this needs extra work to be done.



  • I have to develop an application with QtCreator and QGIS and it seems that I have faced the same problem for more than a week. And finally found this topic (thanks god!). Could you please tell us if you managed to develop your application with QtCreator (and if it is yes, tell us more about it) or if you used VS in the end?


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.