How to remove border with QPushButton?

I have QPushButtons in QTreeView strings and they appear with these black borders around them that I cannot change. Currently I can gray buttons with this code:

for (int i = 0; i < QPalette::NColorRoles; i++){ QPalette::ColorRole thisRole = static_cast<QPalette::ColorRole>(i); QColor newColor = commitPalette.color(QPalette::Disabled,thisRole); int grayColor = qGray(newColor.rgb()); newColor.setRgb(grayColor,grayColor,grayColor,50); commitPalette.setColor(QPalette::Disabled, thisRole, newColor); } 

But he does nothing for the border. I would prefer not to use stylesheets as I like the automatic color generation provided by the QPalette constructor

Example of borders

+6
source share
2 answers

If you are using the Qt creator, right-click on QPushButton and setStyleSheet as border: none; Thats it.

+8
source

If you set the QButton property isFlat = true, it should disable the border if not click.

+5
source

Source: https://habr.com/ru/post/897717/


All Articles