Home > Blockchain >  Different form of using Class in Qt
Different form of using Class in Qt

Time:12-28

I'm trying to use QVersionNumber Class in Qt project. and tried 2 solutions, one is working and another not.

What is the difference between A and B?

in A I'm writing like this:

QVersionNumber imageVersion = QVersionNumber::fromString(payloadRegex_image.cap(3));
QString imageVersionString(imageVersion.toString());

and in B I'm writing like this:

QVersionNumber imageVersion;
 imageVersion.fromString(payloadRegex_image.cap(3))
QString imageVersionString(imageVersion.toString());

CodePudding user response:

That fromString is static public function that does not access this object at all. So in second snippet you ignore its return value and it does nothing.

  •  Tags:  
  • c qt
  • Related