Then here is my question: Is there some way to use critical sections in Qt? Do I need put a mutex in the section I want avoid context switching
What you seem to be indicating is kernel level critical sections, not application critical sections which only deal with concurrent execution. Kernel level critical sections are in kernel mode only and have nothing to do with user applications. Context switching is a kernel level idea, not user mode.
If you are asking about processor affinity, you have to use OS specific commands to set that. Qt does not abstract processor affinity.. This is the only way to be certain that your process will not jump between cores when it is scheduled.
http://msdn.microsoft.com/en-us/library/windows/desktop/ms686247%28v=vs.85%29.aspx
NOTE: There are very few situations where these functions are actually useful. Modern schedulers already want to reschedule a given thread on the same core it was running before to minimize cache misses.
If you are asking about concurrent access to same data structures by multiple threads, then QMutex and similar are what you are looking for.