qmake escape_expand

How do you display multiple-line messages in .pro file? The following code does not work.

message(“First line\nSecond line”)

The backslash is indeed an escape character in the string, but it can only escape one character, i.e, the backslash itself. So the following two lines output the same: First line\nSecond line

message(“First line\nSecond line”)

message(“First line\\nSecond line”)

Similarly \r, \t do not work as well. To display messages in multiple lines, you should use the built-in qmake function escape_expand:

message(“First line$$escape_expand(\n)Second line”)

Since \ can escape \ itself, the following code gets the same result:

message(“First line$$escape_expand(\\n)Second line”)

The official document about escape_expand is not accurate. You do not need to escape the backslash.

 

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