Exploring custom styles
Qt provides several QStyle
subclasses that emulate the styles of the different platforms supported by Qt. These styles are readily available with the Qt GUI module. You can build your own custom styles and export these as plugins. Qt uses QStyle
for rendering the Qt widgets to ensure their look and feel, as per native widgets.
On a Unix distribution, you can get a Windows-style UI for your application by running the following command:
$./helloworld -style windows
You can set a style on an individual widget using the QWidget::setStyle()
method.
Creating a custom style
You can customize the look and feel of your GUI by creating a custom style. There are two different approaches to creating a custom style. In a static approach, you can subclass the QStyle
class and reimplement virtual functions to deliver the desired behavior, or rewrite the QStyle
class from scratch. QCommonStyle
is generally used as a base class instead of QStyle
. In a dynamic...