How to type tab in Qt?

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.

Did you like this?
Tip admin with Cryptocurrency

Donate Bitcoin to admin

Scan to Donate Bitcoin to admin
Scan the QR code or copy the address below into your wallet to send some bitcoin:

Donate Bitcoin Cash to admin

Scan to Donate Bitcoin Cash to admin
Scan the QR code or copy the address below into your wallet to send bitcoin:

Donate Ethereum to admin

Scan to Donate Ethereum to admin
Scan the QR code or copy the address below into your wallet to send some Ether:

Donate Litecoin to admin

Scan to Donate Litecoin to admin
Scan the QR code or copy the address below into your wallet to send some Litecoin:

Donate Monero to admin

Scan to Donate Monero to admin
Scan the QR code or copy the address below into your wallet to send some Monero:

Donate ZCash to admin

Scan to Donate ZCash to admin
Scan the QR code or copy the address below into your wallet to send some ZCash:
Posted in

Leave a Reply