When to use qmake eval?
https://doc.qt.io/qt-5/qmake-test-function-reference.html
eval(string)
Evaluates the contents of the string using qmake syntax rules and returns true. Definitions and assignments can be used in the string to modify the values of existing variables or create new definitions.
For example:
eval(TARGET = myapp) {
message($$TARGET)
}
I wondering when/why that should be used? Can't we just use TARGET = myapp
directly?
do you know?
how many words do you know
See also questions close to this topic
-
C++ increment with macro
I have the following code and I want to use increment with macro:
#include <iostream> #define ABS(x) ((x) < 0 ? -(x) : (x)) int main(int argc, char** argv) { int x = 5; const int result = ABS(x++); std::cout << "R: " << result << std::endl; std::cout << "X: " << x << std::endl; return EXIT_SUCCESS; }
But output will be incorrect:
R: 6 X: 7
Is it possible to somehow use macros with an increment, or should this be abandoned altogether?
-
Can anyone pls tell me whats wrong with my code ? im stuck for the last 3 hours ,this question is bipartite graph in c++
idk why im getting error ,can someone help ? im trying to prove if a graph is bipartite or not in c++
bool isBipartite(vector<int> graph[],int V) { vector<int> vis(V,0); vector<int> color(V,-1); color[0]=1; queue <int> q; q.push(0); while (!q.empty()) { int temp = q.front(); q.pop(); for (int i=0;i<V;i++) { if (!vis[i] && color[i] == -1) "if there is an edge, and colour is not assigned" { color[i] = 1 - color[temp]; q.push(i); vis[i]=1; } else if (!vis[i] && color[i] == color[temp] "if there is an edge and both vertices have same colours" { vis[i]=1; return 0; // graph is not bipartite } } } return 1; }
it gives output "no" for whatever i enter
-
How to assign two or more values to a QMap Variable in Qt
I am getting confused of how to store the values assigned from 3 different functions and storing them in a single map variable
QMap<QString,QString> TrainMap = nullptr; if(......) ( TrainMap = PrevDayTrainMap(); TrainMap = NextDayTrainMap(); TrainMap = CurrentDayTrainMap(); }
The PrevDayTrainMap,NextDayTrainMap & CurrentDayTrainMap returns a set of values with Date and the TrainIdName.I need to store all the values from prevday,currentday and nextday in the TrainMap but it stores only the currentday values to the TrainMap as it is assigned at the last.I am not sure what to do so that it doesn't overwrite.If I should merge what is the way to do it?
-
How to use qmake.conf?
https://doc.qt.io/qt-5/qmake-environment-reference.html mentions
qmake.conf
, but how can I use it? What is the format? What would be one use case for it? -
Makefile with arbitrarily many mains. How to compile all mains with one command?
I am still newish to makefile patterns. I have been working on a project based on a template makefile and project structure, however I have a good sense of what all the makefile instructions are doing.
I would like to modify this so that all the .c files in /src/mains, each with a different main call gets compiled to its own executable.
The original template had no /src/mains folder, and only one file in the /src could contain a main function call.
First the project structure
root | |------ Makefile | |------ build | | | |--- apps | | |--- prog | | |--- hello | | | |---- objects | |--- *.o | |----- include | |--- *.h | |------ src |--- *.c // for each .h (no main calls) |--- mains |--- prog.c (call to main) |--- hello.c (call to different main)
Current Makefile
Without manually writing new linking rules for each make, I found no success. I am just going to leave the cleaner, unmodified makefile here, I'd like to change this so that it automatically builds all the files in mains to /build/apps
As of right now it makes an executable called prog in /build/apps, using a main function call from within /src
CXX := gcc CXXFLAGS := -pedantic-errors -Wall -Wextra -Werror LDFLAGS := -lm BUILD := ./build OBJ_DIR := $(BUILD)/objects APP_DIR := $(BUILD)/apps TARGET := prog # OP: this probably needs to become a wildcard, right? INCLUDE := -Iinclude/ SRC := $(wildcard src/*.c) OFLAGS := -O1 -flto OBJECTS := $(SRC:%.c=$(OBJ_DIR)/%.o) DEPENDENCIES := $(OBJECTS:.o=.d) all: build $(APP_DIR)/$(TARGET) $(OBJ_DIR)/%.o: %.c @mkdir -p $(@D) $(CXX) $(CXXFLAGS) $(INCLUDE) -c $< -MMD -o $@ $(OFLAGS) $(APP_DIR)/$(TARGET): $(OBJECTS) @mkdir -p $(@D) $(CXX) $(CXXFLAGS) -o $(APP_DIR)/$(TARGET) $^ $(LDFLAGS) -include $(DEPENDENCIES) build: @mkdir -p $(APP_DIR) @mkdir -p $(OBJ_DIR) clean: -@rm -rvf $(OBJ_DIR)/* -@rm -rvf $(APP_DIR)/*
If you could modify the Makefile outright that would be great, I would also appreciate any explanation so I don't need a template next time.
Also more generally, How do you like to structure your projects?
Thanks!
-
directxdatabasehelper.cpp No such interface supported
My Windows Qt5 project seems to have something strange.
QApplication a(argc, argv); QDialog d; d.exec(); MainWindow w; w.show(); return a.exec();
While debugging when passing over
d.exec()
, above code will spit outonecore\windows\directx\database\helperlibrary\lib\directxdatabasehelper.cpp(652)\d3d9.dll!00007FFFC322BF65: (caller: 00007FFFC322BA6C) ReturnHr(1) tid(2090) 80004002 No such interface supported
Does not say error or warning anywhere, quite mysterious.
What is that?
-
QtCreator debugger - Enabled, pending, Breakpoint inserted
In Qt5 C++ project, looks like debugger cannot stop on line with a qmake defined variable like
project.pro
TARGET_ = '\\"$$TARGET\\"' DEFINES += PROJECT=\"$${TARGET_}\"
main.cpp
qDebug() << "It stops here"; qDebug() << PROJECT; // It does not stop here qDebug() << "And stops here";
Hover the mouse over the breakpoint, while debugging, and I see:
- Where it stops
Enabled, Breakpoint inserted
- Where it does not stop
Enabled, pending, Breakpoint inserted
What is going on?
-
QtCreator: Header files not found when using CMake
I have tried this on multiple platforms, experiencing the same issue every time.
I successfully build and run my C++ OpenFrameworks application using QtCreator - no problems are encountered.
Then, I successfully use qmake to generate the project file.
Yet when I attempt to make the executable, I receive the following error:
make /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -c -pipe -stdlib=libc++ -O2 -std=gnu++1z -arch arm64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.3.sdk -mmacosx-version-min=12 -Wall -Wextra -fPIC -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -I. -I. -I/opt/homebrew/lib/QtGui.framework/Headers -I/opt/homebrew/lib/QtCore.framework/Headers -I. -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.3.sdk/System/Library/Frameworks/OpenGL.framework/Headers -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.3.sdk/System/Library/Frameworks/AGL.framework/Headers -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.3.sdk/System/Library/Frameworks/OpenGL.framework/Headers -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.3.sdk/System/Library/Frameworks/AGL.framework/Headers -I/opt/homebrew/share/qt/mkspecs/macx-clang -F/opt/homebrew/lib -o main.o src/main.cpp src/main.cpp:1:10: fatal error: 'ofMain.h' file not found #include "ofMain.h" ^~~~~~~~~~ 1 error generated. make: *** [main.o] Error 1
I can go into the .pro file and add things to the include path manually, but I don't see why these includes aren't generated automatically?