Tweaking the digital clock

It's time to make this basic digital clock look more beautiful. Let's add something like a transparent background, which sits on top of the frameless window. Using a transparent background can deliver a fantastic visual effect. While the frameless window hides window decorations, including a border and the title bar, a desktop widget, such as a clock, should be frameless and displayed on top of the desktop.

To make our clock translucent, simply add the following line to the constructor of MainWindow:

setAttribute(Qt::WA_TranslucentBackground);

The effect of the WA_TranslucentBackground attribute depends on the composition managers on the X11 platforms.

A widget may have lots of attributes, and this function is used to switch ...

Get Qt 5 Blueprints now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.