QPushButton border color
-
I want to color the border of a button depending on some conditions. Im currently doing it like this:
ui->buttonCompile->setStyleSheet(uncompiledButton);
ui->buttonCompile->setStyleSheet(compiledButton);
QString uncompiledButton = "border: 2px solid red;";
QString compiledButton = "border: 2px solid green;";
But these things have side effects like the font changing and on Win11 the button will be square. Also the color of the button slightly changes. I want to keep the default look of the button and just change the color of the border. The button is created and defined in mainwindow.ui. How can I achieve that? -
@Grand_Titan
I think you have a problem. Elements have an in-built style. As soon as you place any CSS on them they lose this, that's why you see it look so different. You may find you can only change that in code (QStyle
,QPalette
), not via CSS. -