qt development on linux using eclipse?

2020-02-13 04:22发布

问题:

In Linux, How can I create QT applications in Eclipse? I've seen some integration plugins in eclipse.org however it seems they are discontinued and not supported anymore.

Since I'm going to develop a project which it may be developed for some years from now, I want to find a suitable solution for this.

回答1:

How I do Linux + eclipse + Qt + CMake.

The good thing about it that the sources just use CMake, they are built like if it was just a plain CMake project. And you don't pollute them with the eclipse stuff: the eclipse workspace and project files are outside.

Qt

  • Get latest eclipse and then install the Qt package in it through "Help -> Install New Software".

  • Create an empty "workspace" directory outside the CMake project source directory.

  • Launch eclipse and switch to that "workspace" directory.

  • Create a C++ -> Makefile Project -> Qt Makefile Project.

  • Delete *.pro file, makefile and main.cpp from it.

Sources

  • Go to Project Properties -> Paths and Symbols -> Source Location -> Link Folder.

  • Check "Advanced" and link the source folder of CMake project like that: ../../myproject/. It works because the workspace is just outside the CMake project directory.

CMake generator

  • Create Release folder in the project.

  • Go to "Make Target" view (Ctrl+3 and then type "Make Target" if it's hard to find). "Make Target" view looks just like the project view.

  • Right click on the "Release" folder and "New...".

  • Uncheck "Same as target name", uncheck "Use builder settings".

  • Type in "Release" into "Target name" field, leave "Make target" empty, "Build command" is something like "cmake ../../../myproject/". Click ok.

  • Double click on this "Release" make target that was just created in the Release folder. It should run cmake.

Build

  • Go to Project Properties, create "Release" configuration.

  • Make "Release" configuration active.

  • For "Release" configuration uncheck "Generate Makefiles automatically".

  • Set Build directory to "Release".

  • Enable parallel build.

It should build now in "Release" directory. If it doesn't, remove all from the "Release" directory and rerun cmake by double-clicking on "Release" target in the "Make Target" view as before.

The template for a CMakeLists.txt that I use: https://stackoverflow.com/a/36181462/4742108

CMakeLists editing is done by hand. So you can collaborate with anyone, because to build the software they only need the source files and CMakeLists.txt. (CMake is one of the most wide-spread C++ build systems)



回答2:

I'd recommend using Qt Creator. Before I started with Qt development, I was also using Eclipse for a while, as well as Visual Studio. I tried to keep using these with Qt, but I ended up switching to Creator. It was weird at first, but once you get used to it, it's much better (especially for developing Qt applications).

With Qt Creator, you can develop standalone C++ applications that aren't using Qt. You have the choice of three build systems (that I know of): qmake, qbs and cmake.

As for developing big applications, many companies using Qt do so. Qt Creator itself (which is a massive project) is developed with Qt Creator. :)

A nice part about Creator is that a large portion of the development comes from third party contributors, so there's reassurance that it's easy to contribute patches for things you want to see added and/or fixed.

To get started, download it from here.



标签: linux eclipse qt