Question

Here is the code:

// Latitude line edit
QLineEdit *lineEdit = new QLineEdit;
lineEdit->setInputMask( ">\N999999.99;_" );

But, I am getting compiler warning: Unknown escape sequence '\N' and QLineEdit text does not contain 'N' character, only '_'. What am I doing wrong? Than you all in advance.

Was it helpful?

Solution

In C++, there is a set of defined escape sequences to store special characters into a string.

You are actually lucky that \N is not within this set, because then you wouldn't even get a compiler warning; the text of the warning could have made you learn about escape sequences (unfortunately, it didn't).

Because the \ is used to prefix an escape sequence, you cannot use it directly; it has to be escaped itself:

">\\N999999.99;_"

This compiles to a single >\N999999.99;_ in the output.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top