The TAB character literal can be written as ‘\t’ or ‘ ‘ in your C/C++ source code. They represent the same character. Character literals are enclosed in single quotes while string literals are enclosed in double quotes.
You can create QChar representing the TAB character as follows:
QChar c1('\t'); QChar c2(' ');
The two characters c1 and c2 are equal. However, if you type the TAB character in Qt creator, you will find they are not equal. Meanwhile, you will find the warning message at the c2 line: multi-character character constant. Yes, the single quotes surrounded stuff is a multi-character character which includes 4 spaces. In other words, when you press TAB key while editing your source code in qt creator, the TAB key is replaced by four space characters. You’d better use the escaped representation of the TAB character \t here. But the tab behavior can be changed by “Tools/Options/C++/Code Style/General/Tab Policy:Tabs Only”. The default Tab Policy is “Spaces Only”. After you change the tab policy, you can type the TAB character directly in your source code.