In the process of applying qt developed on Windows to Linux
-

I have a question during the process of applying qt developed on Windows to Linux.
I'm getting this error after building, is it because the syntax is different? how can i solve it?@IknowQT said in In the process of applying qt developed on Windows to Linux:
is it because the syntax is different?
I've never seen
inused in a C++ for-loop before. Did it really work in Windows? What compiler did you use?Replace
inwith,foreach (auto item, m_vIncuMgr) { ... }Even better, use the C++11 range-based for-loop: https://en.cppreference.com/w/cpp/language/range-for
Also, in the future, please post text, not a screenshot.
-
@IknowQT said in In the process of applying qt developed on Windows to Linux:
is it because the syntax is different?
I've never seen
inused in a C++ for-loop before. Did it really work in Windows? What compiler did you use?Replace
inwith,foreach (auto item, m_vIncuMgr) { ... }Even better, use the C++11 range-based for-loop: https://en.cppreference.com/w/cpp/language/range-for
Also, in the future, please post text, not a screenshot.
-

for each (auto item in m_vIncuMgr) { item->setCurremtStep(Index++); }There was nothing wrong with the build and it worked well.
Anyway, thanks for checking the issue.@IknowQT said in In the process of applying qt developed on Windows to Linux:
There was nothing wrong with the build and it worked well.
I also never saw such a for loop in C++ (looks rather like a Python for loop)! Maybe this is something Microsoft invented in their C++ compiler. Anyway you should use what C++ standard specifies.
-
foreach (... in ...)is a C# construct, andfor (... in ..)is a JavaScript one. Neither is right for Python. Not for C++, where Qt has aforeach()macro with different syntax.The
for each (... in ...)is an MSVC-only C++ construct, per https://docs.microsoft.com/en-us/cpp/dotnet/for-each-in?view=msvc-160, and it warns:This non-standard keyword is available in both C++/CLI and native C++ projects. However, its use isn't recommended. Consider using a standard Range-based for Statement (C++) instead.
:D