Solved Reading python script and store as string at compile time?
-
I'm using C++ version of Qt, I want to read some python script and store them as strings at compile time. I tried copy and pasting them into the cpp file and read them as raw string literal. It works but since python script is space sensitive, they looks so ugly when pasted in a cpp file
QString pythonScript = R"(import abc as apple print("1") def = "hello")";
Is there better ways to do this?
-
Hi
You could use a resource file and store a .py file there and load it. -
Thanks I tried the resource system and it works.
QFile file(":/python_scripts/script1.py"); file.open(QIODevice::ReadOnly | QIODevice::Text); QString pythonScript = file.readAll();