Clipping of (OR maybe background colour of) QToolbar Icons
-
@mrjj I changed the ctor so it starts with:
constexpr int radius = 27; QColor colour = palette().window().color(); colour = colour.lighter(300); colour.setAlpha(205); QString styleSheet(QString( "QToolButton {background - color:transparent;} " "QToolBar " "{background-color: %1; " "border-radius: %2px;}" ) .arg(colour.name(QColor::HexArgb)) .arg(radius) ); setStyleSheet(styleSheet);
Unfortunately, it didn't seem to help any:
-
@mrjj I changed the ctor so it starts with:
constexpr int radius = 27; QColor colour = palette().window().color(); colour = colour.lighter(300); colour.setAlpha(205); QString styleSheet(QString( "QToolButton {background - color:transparent;} " "QToolBar " "{background-color: %1; " "border-radius: %2px;}" ) .arg(colour.name(QColor::HexArgb)) .arg(radius) ); setStyleSheet(styleSheet);
Unfortunately, it didn't seem to help any:
-
@Perdrix said in Clipping of (OR maybe background colour of) QToolbar Icons:
{background - color:transparent;}
This may be quite orthogonal to your issue, but are you sure this is acceptable written like that?
-
@JonB I wasn't sure so I changed it. And this is what I now see:
So changing it to:
QString styleSheet(QString(
"QToolButton {background-color:transparent;} "did change things and not for the better :(
So "background - color" was wrong!
-
@JonB I wasn't sure so I changed it. And this is what I now see:
So changing it to:
QString styleSheet(QString(
"QToolButton {background-color:transparent;} "did change things and not for the better :(
So "background - color" was wrong!
@Perdrix
I know nothing :) But (provided I understand right) I would expect:QToolButton{border: none; background-color: transparent;}
(I assume you have the correct transparency on your icons. Perhaps you should confirm this?)
Just OOI isn't that what https://stackoverflow.com/questions/69755056/how-to-set-qaction-to-have-transparent-background-inside-qtoolbar says and is similar enough to yours??
-
@JonB I wasn't sure so I changed it. And this is what I now see:
So changing it to:
QString styleSheet(QString(
"QToolButton {background-color:transparent;} "did change things and not for the better :(
So "background - color" was wrong!
If anything else fails, then you can try setMask
If does make the area round/as the icon but can a bit annoying to align.
More over, the checked default drawing might not be visible.#include "QBitmap" // must have to use setmask .... setStyleSheet(styleSheet); auto list = ui->toolBar->findChildren<QToolButton *>(); for (auto *w : list) { w->setAutoRaise(false); QIcon ico = w->icon(); QPixmap pix = ico.pixmap(ui->toolBar->iconSize()); w->setMask(pix.mask()); }
-
@Perdrix
I know nothing :) But (provided I understand right) I would expect:QToolButton{border: none; background-color: transparent;}
(I assume you have the correct transparency on your icons. Perhaps you should confirm this?)
Just OOI isn't that what https://stackoverflow.com/questions/69755056/how-to-set-qaction-to-have-transparent-background-inside-qtoolbar says and is similar enough to yours??
-
@Perdrix
I know nothing :) But (provided I understand right) I would expect:QToolButton{border: none; background-color: transparent;}
(I assume you have the correct transparency on your icons. Perhaps you should confirm this?)
Just OOI isn't that what https://stackoverflow.com/questions/69755056/how-to-set-qaction-to-have-transparent-background-inside-qtoolbar says and is similar enough to yours??
-
P Perdrix has marked this topic as solved on
-
@JonB You sir, are a star! border:none; made the difference!!!
So:
QToolButton {border: none; background-color: transparent;}
worked a treat!
Why did adding border:none; fix it please?