A signal mapper is a useful tool when we need to perform almost the same action for many signals. Instead of checking the "caller" in the slot, and making the decision based on that, we can create a "mapping" between a signalling object and some identifying parameter. Now, our handling slot takes the id parameter and makes its decision based on that.
Using a signal mapper can save us subclassing a QPushButton for an id. Here's a short usage example.
The Qt style sheets lets us customize the look & feel of our widgets without subclassing them. Keep in mind, though, that the best way to use a style sheet is by creating customized "themes" for the application, so that all ui components will look more or less in the same spirit. Although designing a theme can take some time, once it's done everything looks better.
Be sure to include the qss file in a Qt resource file under the /styles directory for this to work.
Once you have the qss ready, using it on an app is a breeze, here's the code (and a sample qrc file):
Implementing a Qt friendly value object can be a bit cumbersome, but it is worth your time. A Qt value object can be stored in containers (such as lists or in hash values), can be used as hash keys, and stored inside QVariant.
Here's a working example for a custom Qt friendly value type.
The Contact class features the following:
An event filter is installed on a widget and gives us a chance to manipulate events before they reach that widget.
Every QObject class can be installed as an Event Filter, and all it needs to do is implement the eventFilter(QObject *obj, QEvent *evt) method. The method should return "true" if we want to block the event (so it won't reach the target widget), or false if it can pass through the filter.