qmake

How to add specific flags to moc in a qmake project?

不羁岁月 提交于 2019-11-28 03:24:32
问题 I compile a Qt executable using qmake && make on the following project.pro file: INCLUDEPATH *= ../../dependencies/boost QT *= opengl xml CONFIG *= qt opengl static TARGET = myexe HEADERS = Viewer.hpp MainWindow.hpp Inspector.hpp SOURCES = main.cpp Viewer.cpp MainWindow.cpp Inspector.cpp However, when compiling, moc chokes on a boost macro which it cannot parse. To work around this bug, I need to pass the flag -DBOOST_TT_HAS_OPERATOR_HPP_INCLUDED to moc, but I cannot manage to do so. How to I

Why does qmake put all object (.o) files to one directory?

Deadly 提交于 2019-11-28 02:28:30
问题 Let's say I have a Qt application where I have two classes with the same name in two different namespaces: namespace namespace1 { class SomeClass; } namespace namespace2 { class SomeClass; } and I have a project directory structure according to it: -->src/ -->namespace1/ -->someclass.cpp -->namespace2/ -->someclass.cpp When I compile the application with qmake, it puts all object (.o) files to one directory - so it creates someclass.o file first and then it rewrites it with the second

Qt project files and PREFIX variable

泪湿孤枕 提交于 2019-11-28 00:33:13
问题 I included PREFIX = /usr/local inside my project file and then I run qmake myproject.pro The makefile doesn't say anything about PREFIX though so I assume that i'm doing something wrong. Any ideas? 回答1: PREFIX doesn't mean anything in qmake files. The target for files is done via the target parameter. So if you want to make PREFIX determine the base location, such as /usr/local , you can do do something like this: isEmpty(PREFIX) { PREFIX = /usr/local } TARGET = myapp TARGET.path = $$PREFIX/

Running a program/script from QMake

自作多情 提交于 2019-11-27 22:55:18
We have a fairly large code-base. The vast majority of the code is compiled using qmake to produce the makefiles. However, there are some sub-projects that get produced by running batch files or running other programs. I'd like to be able to have everything compiled using qmake, but I can't figure out how to get qmake to simply run a script. One thing that I've tried is using QMAKE_EXTRA_TARGETS in my pro file, like so: TEMPLATE = lib SOURCES = placeholder.cpp CONFIG += no_link staticlib batch_runner.target = placeholder.cpp batch_runner.commands = my_batch_file.bat QMAKE_EXTRA_TARGETS = batch

Identifier for win64 configuration in Qmake

我是研究僧i 提交于 2019-11-27 20:27:47
Is there a "win64" identifier in Qmake project files? Qt Qmake advanced documentation does not mention other than unix / macx / win32. So far I've tried using: win32:message("using win32") win64:message("using win64") amd64:message("using amd64") The result is always "using win32". Must I use a separate project-file for x32 and x64 projects, so they would compile against correct libraries? Is there any other way to identify between 32-bit and 64-bit environments? did I do it like this win32 { ## Windows common build here !contains(QMAKE_TARGET.arch, x86_64) { message("x86 build") ## Windows

Eclipse, QT and “C++ project”: is it possible?

强颜欢笑 提交于 2019-11-27 18:24:04
问题 Need your help: I want to use Eclipse CDT and QT without creating a "Qt gui project". Is it possible? How to include QT libraries to my C++ project, and how to call qmake/make to compile the program? This Similar question didn't help me( I want to use 'C++ project' instead of 'QT Gui project' because there is an issue with external libraries indexing in the QT project (this problem) Thank you a lot! Nikolai. 回答1: Doing this is quite bothering, I suggest you don't do it. I've tried it only on

How to create a subdirectory for a project QtCreator?

▼魔方 西西 提交于 2019-11-27 17:33:42
I would like to divide my Qt project into several directories because it is growing pretty large. However, when I click on browse in QtCreator, there is no 'Add directory' and no such thing in 'Add new'. Can this be done somehow? One method you could use is to add a project include file for each sub directory. Qt Creator displays these in the GUI in a nested fashion, and allows you to add files to them. e.g. in project.pro include(folder1/include.pri) in folder1/include.pri HEADERS += MyClass.h SOURCES += MyClass.cpp etc Answer : How to create a folder or a subdirectory for a project in

Unknown module(s) in QT: svg

狂风中的少年 提交于 2019-11-27 17:06:40
问题 Added QT += svg and I tried just QT += svg and greaterThan(QT_MAJOR_VERSION, 4): QT += svg to the .pro solution file and ran qmake from inside the QtCreator and got this error: error: Unknown module(s) in QT: svg Any ideas? 回答1: You are lacking the installation of the the QtSvg library. Try to install them on your Ubuntu 13.10 in the following way: sudo apt-get install libqt5svg5* 回答2: Debian Stretch: sudo apt install libqt5svg5-dev Fedora (courtesy of @robin-green): sudo dnf install qt5

Finding compiler vendor / version using qmake

血红的双手。 提交于 2019-11-27 15:02:46
问题 Is there any way to get the version and vendor of the compiler used by the user through qmake? What I need is to disable building some targets of my project when g++ 3.x is used and enable them when g++ 4.x is used. Update: Most answers targeted the preprocessor. This is something that I want to avoid. I don't want a target to be build for a specific compiler version and I want this decision to be made by the build system. 回答1: In addition to ashcatch's answer, qmake allows you to query the

How do a specify a library file dependency for qmake in Qt?

≡放荡痞女 提交于 2019-11-27 12:31:35
问题 Have a SomeLib.pro file that contains: CONFIG += debug TEMPLATE = lib TARGET = SomeLib .. Then in a dependent SomeApp.pro: .. debug:LIBS += -lSomeLib_debug .. How can I force SomeApp to build if I touched SomeLib in qmake? 回答1: It's ugly because you need to give the exact library file name, but this should work: TARGETDEPS += libfoo.a 回答2: QT Creator will do the work if you click "Add library..." in the context menu of the project that should include the library. These variables are