QToolBar Border setStyleSheet()

c++, qt

Solution

You're right, styling one or more of the borders (including removing it) ends up removing the rest. This is because style sheets and Qt Styles don't mix very well, and the Qt Style usually loses.

What you can do is bring back the borders you do want to see. This example specifies how the top and bottom borders should appear, which in turn removes the left and right boders:

toolBar2->setStyleSheet("QToolBar {border-bottom: 2px solid black; border-top: 2px solid black;}");

Problem

I have a number of QToolBar's in Qt::TopToolBarArea of my QMainWindow. I want to remove the left and right borders from the ones which are not on the edges. However, when try the following code, it ends up erasing ALL of the borders on the QToolBar: toolBar2->setStyleSheet("QToolBar { border-left-style: none; border-right-style: none; }"); I want this to appear as one continuous tool bar, with no borders between them. What is the proper way to achieve this?

Original source