More thoughts on Qt 4.5
I've been using Qt 4.5 for a couple more weeks now and I've had a few more thoughts on the framework.
- I don't know if I could handle using the plain Win32 API for GUI ever again
- Even with Qt's "parent handles the deletion of its children" memory management system it's still easier to use (and reason about)
shared_ptr
or another smart pointer, as long as you're not working with widgets or similar GUI elements. If you're working with GUI elements, Qt's memory management works perfectly and makes sense. - You can assume that any
addWidget()
-like function will take ownership unless explicitly stated otherwise. I still wish they would just say straight out that "this function takes ownership". - In my opinion the documentation would be much improved for newcomers if they had a "Qt Best Practices" section. You can get a sense of how things should be structured if you look at their sample programs, but there's a lot to go through.
- Other than those two nitpicks, the documentation is consistently quite good.
- I would suggest that you avoid using the Qt containers and instead favor the standard C++ containers whenever possible. There's less to learn, and most C++ programmers will have a firm grasp of the containers in the
std
namespace. Some Qt functions do returnQStringList
or some other Qt container, in which case you may as well just leave it in the container you get it in. - On the other hand, if you're going to use Qt, you may as well use
QString
everywhere. It's used extensively through the Qt framework, so you won't be able to avoid it. It's a pretty decent string library anyway, with plenty of useful functions, and it handles Unicode cleanly in my experience. QTextEdit
isn't particularly performant, particularly when you resize it and it has to perform lots of word wrap calculations. UseQPlainTextEdit
if you can.