Search code examples
c++qtqregexp

QRegExpValidator parameters


If I write the following:

QValidator *validator = new QRegExpValidator(regExp, this);

What does this mean here? What is it referring to? If I don't use it what effect will occur?


Solution

  • this is a pointer to the current class where validator is declared in.

    its there to let QRegExpValidator know who is the parent of validator so whenever the parent is deleted, so as validator. this way you dont need to delete it manually.

    More about the this pointer, see here