This "solution" is just to enable syntax highlighting. Try the following very basic code:
__global__ void hello() {
printf("This is a test");
}
int main(int argc, char* argv[])
{
hello<<<1,1>>>();
return 0;
}
The code above is a very basic example for CUDA source file that includes a kernel definition and will cause a lot of problems with Qt Creator. I am guessing the same will happen if we use __device__. Adjusting the MIME type for C++ to include CUDA helps only with the syntax highlighting. Ultimately CUDA, while being very, very similar to C/C++, is a different language that requires its own language model that is not included in Qt Creator as well as a compiler, which - through CMake - can somewhat be integrated into the IDE. If you want to develop with CUDA and CMake I would suggest using VS Code or Visual Studio with the second still (2019 edition) having a not that great support for CMake). Last but not least the devs from NVidia have done a really sloppy job in regards to offering integration of the CUDA infrastructure in popular IDEs. It takes hours if not days to make a setup that just works.