Y have trolltech declared className() as a member function rather than a static function ?
Printable View
Y have trolltech declared className() as a member function rather than a static function ?
Please, don't use such ugly abbreviations.Quote:
Originally Posted by sunil.thaha
Because it wouldn't make sense. You need className() when you don't know the class name.Quote:
Originally Posted by sunil.thaha
If className() was static, you would have to use it like this:
Or you can write simply:
The effect is the same and in either case you will have to change your code when you rename your class. The only difference, is that in former case you won't make a typo.
Now consider this:With inheritance mechanism, you can have a pointer that points to an instance of some class derived from a base class, but you not necessarily have to know which one and that's when you have to invoke className().Code:
BaseClass *base = new SomeClassDerivedFromBase(); qDebug() << base->className();
Beauty lies in the eyes of the viewer ;). Anyway I will take care.Quote:
Originally Posted by jacek
That makes sense.Quote:
Originally Posted by jacek
But I did not find the virual keyword in the assistant. That would have given the clue... :rolleyes:
It isn't virtual in Qt4, because it's a part of Qt3 Support module and a shorthand for "metaObject()->className()".Quote:
Originally Posted by sunil.thaha
Hear! hear! At last someone finally said it. Bastardizations of the English language such as 'U', 'Y', 'UR' '4" '2', etc. etc. are just ignorant and lazy (unless of course you are using a mobile phone, where it really is quicker and only the recipient has to tolerate the sloppy use of language).
Just had to get that off my chest...
FYI:
There is a undocumented staticMetaObject which is a public datamember in Qt 4.1.x and IT is documented in Qt 4.2
As you may have noticed we try to keep the language used clean and we ourselves try to use British English whenever possible, which in my opinion is much more pure than American English, which also explains why this site is called Qt Centre and not Qt Center :)
As much as I enjoy besmirching American English, there's nothing really pure about British English. It's a mishmash of various languages with as many exceptions as it has rules. It is also inconsistent in many places. Anyone who has become fluent in it as a second language has achieved a lot as far as I'm concerned.