Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've been a longtime PHP web developer. But now I've reached the limits and web doesn't fascinate me anymore. I am interested in learning cross-platform development. I have learned Java for almost a year and know much of its OOP concepts but I would like to develop high-performance cross-platform programs and I find Java to be somewhat slower unless you have a beast hardware.

Searching for programming books on C and C++, I have only found that they only covers the basics which are same for every language. Datatypes, Loops, Conditionals, Operators etc. But the languages are no more this minimal. C++ provides STL and I've yet to find a book which shows you how to develop real-world programs using these standard features.

I know PHP very well, I have known ins and outs of MVC and Singleton Design Patterns, but then I stumbled upon Qt Framework and some of the apps it has powered: Skype, VLC, KDE and they all are rock-solid. I've NEITHER faced any bugs or crashing issues with these applications on Windows NOR on Linux.

My request How should I approach learning Qt? The biggest difference I'm encountering is C++'s static typing which is very different than the dynamically-typed languages (PHP, Python etc.) I have already worked with.

share|improve this question

closed as off-topic by gnat, GlenH7, Bart van Ingen Schenau, Robert Harvey, Wayne M Jul 10 '14 at 0:43

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions seeking career or education advice are off topic on Programmers. They are only meaningful to the asker and do not generate lasting value for the broader programming community. Furthermore, in most cases, any answer is going to be a subjective opinion that may not take into account all the nuances of a (your) particular circumstance." – gnat, GlenH7, Bart van Ingen Schenau, Robert Harvey, Wayne M
If this question can be reworded to fit the rules in the help center, please edit the question.

As you say, C++ is a strongly typed language. Skipping C++ material (books, courses) because you think you know loops, conditionals etc is a bad idea. I have some courses at Pluralsight you might like - they have a free trial. Learn C++ concepts, especially stack semantics, strong typing, and using templates - then learn Qt. – Kate Gregory Jul 6 '13 at 14:46
Check out Bryan Cairns's excellent, free C++ Qt programming tutorials, almost 24 hours of tutorials! – Geremia Apr 14 '15 at 5:55
up vote 3 down vote accepted

You should learn both. As Qt is implemented in C++, you need to learn C++ to be able to use it effectively and correctly anyways. So that's where to start. A good understanding of the language itself and the standard library will give you a solid foundation to understand Qt, and how to use it as well.

As for a good book to learn C++, I like Koenig and Moo's Accelerated C++. There's probably books that combine C++ with Qt for learning too, but I don't know them.

Edit: Some additional points: C++ is a large and complex language. In addition to the static typing, you also have to deal with memory management and object lifetime, etc. in ways you will not be used to from dynamic languages. Method resolution and overloading is another area which may be quite different from what you already know. The language makes all the tools you need to handle these issues efficiently if you know how to use them.

My suggestion is to try to learn the language from afresh, not comparing it to any of the dynamic languages you may already know. Learn the basics and understand the established patterns (RAII, The Rule of Three, etc) well! This will help you many times over, both in designing good code, in resolving cryptic compiler error messages, and tracking down bugs in the code.

share|improve this answer

If you're having problems because of the static typing then its obvious what the problem is: its the old dynamic programmer mindset. C++ requires you to know what you're doing before you do it, whereas a lot fo scripting languages, you can just make things up as you go - C++ requires you to know the type of object you're working with, whereas a script language... you just figure it out later when you have the object. So take much more time on design than you used to do. Create class diagrams maybe which should help you sit down and think about your application. Its all about discipline in "doing things right".

As for tutorials. There's a few for Qt on their website. As for STL, you don't need all of it, generally using the collection classes (and know which ones to use when) is 80% of all STL work, the other 20% is iterators. STL tutorials are all over the web.

share|improve this answer
The thing is that I know much of Java which is also a statically typed language. So this wouldn't be much of a problem to grasp in C++. But I've decided to learn Standard C++ first, before getting my hands dirty in Qt. So now I'm grabbing the "Accelerated C++" book as suggested by harald above. Thanks for mentioning your suggestions. – khalid Jul 8 '13 at 5:00

You can separate C++ from Qt. You can learn Qt with a dynamic language such as Python (use PyQt), and you can learn C++ without Qt (any number of books). It's good to learn new stuff, but if you learn Qt and C++ at the same time, you might get confused which is which. One of the really annoying things about Qt is that it has its own QString vs. std::string (although some people say that QString is better

share|improve this answer
Thanks for pointing out PyQt. I've heard good things about PyQt and known that Python has the most brilliant Qt bindings available. But I want to learn the things under the hood such as memory management issues etc. in C++. So I've decided to first learn C++ properly and then proceed to Qt. – khalid Jul 8 '13 at 5:03

I would not recommend trying to learn Qt without first knowing C++. Personally I've recently started using Qt myself, and I also use the Python binding PySide (alternative to PyQt).

The thing is that Qt uses many basic C++ language features to manage the framework, and without an understanding of those basics you'd quickly get lost in the Qt jungle. I'd go so far as to say that trying to learn Qt bindings such as PySide/PyQt without knowing how Qt works with C++ first is a bit of a risk as well.

My advice is to get a book called "An Introduction to Design Patterns in C++ with Qt". Link to the book here.

It claims to be the only source you need for learning the core C++ needed, though I disagree. But it's a really good book, relatively updated to use the QtCreator IDE and has lots of useful information in it.

But. I know it's not what you want to hear, but personally I'd try to learn as much C++ as possible before starting with this book. There is a good book called "C++ Primer" (not primer plus) that takes you from scratch and into pretty advanced C++, and even though it takes a while to read it, you'd be glad you did. I just checked the latest edition and it includes all features from the latest C++11 standard, making it a bit easier to grasp some of the language features.

I believe learning Qt is a wise choice these days, but so is learning C++11. More and more companies are investing money in C++ now compared to a few years ago, and that is partially because Microsoft is investing a lot in C++11 and C++14 these days. You can check out the increased support in the latest beta of Visual Studio 2013 to see the proof of this.

Besides, take a look at this presentation: The future of C++ by Herb Sutter, where he talks about Microsoft's commitment in C++.

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.