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 on or switch off a specified attribute. It's turned on by default. You need to pass a false Boolean as the second argument to disable an attribute. The full list of Qt::WidgetAttribute
can be found in the Qt Reference Documentation...