Where should I start from if I want to study the source codes of Qt?
I would like to study about the source codes of Qt5 with my spare time(I want to learn some skills from the codes).
Which module would you suggest to start with?Any comments, books or resources could be a guide?
For those experiences programmers, maybe this is an easy task, but I am just a fresh programmer and don't know
where should I begin.
If you are a fresh programmer, it's probably much better to learn by writing your own programs/ applications.
If you really insist on learning Qt code, a good place to start is definitely the QtCore module, and stuff like QString, QByteArray etc. But don't expect to understand it too easily - this code focuses on performance, API and ABI stability, so it might be really hard to understand.
Thanks for your comments, I am writing my own programs/applications everyday. But I also
want to study the source codes of other, even I can't understand all of them, I may learn
something from the codes.
bq. But don’t expect to understand it too easily
Don't worry, I don't think I can understand all of the codes for now, just like STL, even I haven't
understand all of the source codes of STL, I still learn something from the source codes.
Ex : compile time polymorphism, functional programming, some template skills and design
pattern.SGI STL is very amazing, I never though a "simple" program like std::copy could
be so interesting(thanks for template)
I will take a look at QString and QByteArray. If I have problem I may come back and ask.
Ah ok, from the initial post I understood that you are really new to programming, and for a total rookie Qt sources can be really too hard to understand at times (especially because of PIMPL implementation - it does marvels to the ABI, but is damn hard to digest at first sight (and at second and third ones, too :) )).
What I would also recommend is to try to contribute to Qt (a bugfix, or a new proposed class, etc.) - then you not only have more hands-on experience, but also benefit from the marvellous review system in Qt. Last year I tried to push web service convenience classes to QtNetwork. Although they were not included in the end (my fault - I got carried away by other projects), I got some really fantastic feedback on general code style, some various techniques etc. by Thiago, and other API help from dev mailing list. That really taught me a lot.
Don't go too deep. In my opinion Qt code becomes ugly and not suitable as a programming style role model when looking at the depths of e.g. the cross platform drawing stuff. Lots and lots of bad practices like highly condensed/nonsensical variable names, useless or no commenting, etc.
Further, Qt's code won't show you so much about how to program with Qt. In my opinion writing pure C++ is very different from writing QtC++.How about looking at a project that uses Qt?
If on the other hand you're interested in how such cross-platform frameworks are built under the hood, go right ahead. Start with whatever component interests you. If you like QLabels, look at QLabels. If you wonder how tooltips are done, look at QToolTip. If you're wondering how those containers work, look at QVector and QList. Qt is not a book, there is no beginning and no end ;)
bq. Lots and lots of bad practices like highly condensed/nonsensical variable names, useless or no commenting, etc.
I though it is pretty normal in a big project, but no refactor?
bq. How about looking at a project that uses Qt?
Could you recommend some examples?Better start from simple cases.
Need to know more about how to design good software,
I hope someday I would good enough to live as an independent developer.
bq. Further, Qt’s code won’t show you so much about how to program with Qt
Program with Qt is fun, but I want to know more than that.
bq. What I would also recommend is to try to contribute to Qt
I would like to do that so if I have the ability.
For example you could look at source code of those projects:
Launchy (I used to use it heavily on Windows XP, still far better then Windows Search in start menu) http://sourceforge.net/projects/launchy/
ChessX (if you're into chess you could find it useful, this projects needs developers)