Y have trolltech declared className() as a member function rather than a static function ?
Y have trolltech declared className() as a member function rather than a static function ?
We can't solve problems by using the same kind of thinking we used when we created them
Please, don't use such ugly abbreviations.Originally Posted by sunil.thaha
Because it wouldn't make sense. You need className() when you don't know the class name.Originally Posted by sunil.thaha
If className() was static, you would have to use it like this:
Or you can write simply:Qt Code:
To copy to clipboard, switch view to plain text mode
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.Qt Code:
To copy to clipboard, switch view to plain text mode
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().Qt Code:
BaseClass *base = new SomeClassDerivedFromBase(); qDebug() << base->className();To copy to clipboard, switch view to plain text mode
sunil.thaha (15th September 2006)
Beauty lies in the eyes of the viewer . Anyway I will take care.Originally Posted by jacek
That makes sense.Originally Posted by jacek
But I did not find the virual keyword in the assistant. That would have given the clue...
We can't solve problems by using the same kind of thinking we used when we created them
It isn't virtual in Qt4, because it's a part of Qt3 Support module and a shorthand for "metaObject()->className()".Originally Posted by sunil.thaha
sunil.thaha (18th September 2006)
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...
Save yourself some pain. Learn C++ before learning Qt.
FYI:
There is a undocumented staticMetaObject which is a public datamember in Qt 4.1.x and IT is documented in Qt 4.2
We can't solve problems by using the same kind of thinking we used when we created them
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
Last edited by wysota; 15th December 2006 at 11:25.
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.
Save yourself some pain. Learn C++ before learning Qt.
Bookmarks