Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
625 views
in Technique[技术] by (71.8m points)

qt development on linux using eclipse?

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...