Should the name of my classes begin with 'Q' in Qt?
When I first started working with Qt, it was extremely annoying that every class has a name beginning with 'Q', but now I've got used to it.
I'm using Qt Creator, and it highlights code quite well.
However, it only highlights class names beginning with 'Q'. And it highlights everything beginning with 'Q' even if there is no such type.
It doesn't highlight custom class names.
That makes me wonder, should I also begin all my class names with 'Q'?
Or at least the reusable ones?
(I mean, those that I put in a class library, or reuse in another app.)
I've seen several places where they named their classes this way. Is it a good thing?
I found this page about Qt's naming conventions, but it doesn't deal with this question.
Also, I don't understand why Qt doesn't use namespaces.
EDIT:
Big thank you to everyone who shared his thoughts with me.
EDIT 2:
It seems that the newer versions of Qt Creator now also highlight the class names not beginning with 'Q'. Nice!
Personnally, I wouldn't prefix my own classes. As Qt has its own implementation of lots of thing (string, list...) it helps to know what you're using.
The correct way would be to use namespaces. I think that Qt didn't use them because it's quite old. C++ changed a lot lately.
And generally, adapting your naming conventions according to syntax colouring is a bad idea (even if I understand that it only made you wonder about your nameming).
I can't see why you would want to enforce this on your own classes at all. Let Qt do what it wants to do with its class naming convention and you do your own.
Use your own coding convention and standards, it doesn't have to match the library you're using. I don't think the makers of Qt are implying that you follow their style conventions.
链接地址: http://www.djcxy.com/p/39288.html上一篇: 如果鼠标点击它外部,关闭窗口小部件窗口
下一篇: Qt中我的课程名称应该以'Q'开头吗?