Style a QToolBoxs Page with QSS

Solution

Targeting a QToolBox’s page widget with QSS selectors can be tricky. Our intuitive mind would try

But that won’t work. The correct way to do it is

Why?

QToolBox [qt-project.org] creates a new QScrollArea [qt-project.org] for every page as a container to provide scrollbars if necessary. Additionally QScrollArea also creates another widget as a viewPort. So our QWidget [qt-project.org] page will be the direct child of that viewPort.

Categories: