2 ms·
Inheritance; many Qt provided objects can (and should) be extended by you, to provide more functionality while still being Widget objects that can be displayed
by EliRivers 10y ago
Inheritance; many Qt provided objects can (and should) be extended by you, to provide more functionality while still being Widget objects that can be displayed as expected and interact with other Qt objects. Coupled with this, how to feed an object of derived type to something expecting an object of base type, without slicing it or otherwise shooting yourself in the foot. Qt tends to pass QObjects around with pointers, which does make it harder to get this wrong.
Objects; they're all objects. Understand objects.
RAII/Constructors and destructors; managing object and resource lifetimes, and suitably ensuring that visual widgets and other such Qt objects are created and disposed of properly.
Threads; Qt Widgets (and your own objects) spark actions in Qt objects through signals and slots (fancy Qt meta-programming that takes care of a lot of boilerplate for you), that have rules about working across threads. Understanding threads is needed to understand these restrictions, and the GUI rule of "stay off the GUI thread" applies always, if you don't want to lock up the GUI. This means you'll need to create other threads to do the heavy lifting. You don't have to use standard C++ threads, but you'll need to understand threading.
Don't use QList unless you really have a good reason, even if you find old documentation saying you should.
- joezydeco 10y agoI find the QThread class does a good job of abstracting the thread work, especially if you're going to hop between Linux/pthreads to Win32-64/whateverthehelltheyuse. And the signals/slots do a great job of marshalling data across the threads, which is where I've found a lot of C++ projects get into the weeds.
- bakery2k 10y agoThanks for your reply. What little C++ experience I have is from several years ago - do you think (again, purely in the context of Qt) that any of the new C++11 features are worth using or should I stick to C++98?
- EliRivers 10y agoAs a rule of thumb, they're all worth using. C++11, to repeat something that's becoming a cliché, is like a whole new language. Even in the context of Qt, it's worth using some C++11. auto, lambda functions, shared and unique pointers, (although QT has always provided its own versions of these), C++ 11 threads. I code heavily with Qt and I use these C++11 features daily. C++11 changes some things that used to be almost impossible into possible, and some things that used to be awkward maintenance headaches into natural and flowing code. This is great; this is an opportunity for you to get to grips with some modern C++.