qtoolbutton/qpushbutton icon based on button's size
-
@user4592357
Can you show that effect ?
It wont scale the icon, but keep the size to IconSize.
Why dont just paint it directly ? ( inherit ToolButton and implement paintEvent ) -
Hi
Like
with a small custom class.
Test project
https://www.dropbox.com/s/62flul5h8aa5shj/PatternButton.zip?dl=0How do you determine the pattern it should use ?
I just used variables inside, but if you generate the buttons you could just give
as parameters. -
oh, the problem was that i was calling
QToolButton::paintEvent(event);
in the end.
without it the patterns are being drawn.
but if i don't call it, well, my button isn't a button and cannot be pressed, etc. -
@user4592357
If you dont call QToolButton::paintEvent(event), the button
can still be pressed but it wont draw the effect.
But will send signal though.You can just do it revers
call QToolButton::paintEvent(event) in top
then draw pattern with slightly smaller rect on top of what already drawn.
(i assume you need no texts) -
@mrjj
i managed to do that but i want to remove all spaces between buttons.
i've setsetContentsMargins(0, 0, 0, 0)
andsetSpacing(0)
for the layout.
this is what i have now: https://ibb.co/qYCm8vR
can't i remove those spaces? -
@user4592357
Hi
The tool buttons seems to reserve some pixels so there will be a small space.
The lower ones are Frames and both layouts have same settings so its fair to say
its the closest you get with ToolButtons as seen in top. -
@mrjj
hi,
when i add the buttons to a layout, they take up more space (just because it's available).
how can i make the buttons be in their minimum size in that layout?p.s. this is what i have set for the button:
setMinimumSize(...); setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
-
@user4592357
But would would be the minimum ?
You can set setMaximumSize of them if you want to limit it to
certain size. like 64x64. else layout makes them use the extra space. -
@user4592357
im not sure i understand.
You do not want a max size for widgets but at same time they are not allowed to use
all the space ?
well yes spacers should compress to minimum -
yes maybe that's weird but that's what i need.
when i added the spacer at col 0, and then the rest of the widgets, only the first widget got added. -
@user4592357
Im not sure what you mean . Adding cant fail due to spacer.
did you set Minimum on the widgets as else they get compressed totally.with no Minimum set
-
i added spacers at both ends of hbox layout, but now the whole container widget gets larger instead of the buttons getting smaller (since there is a spacer around them)...
-
@user4592357
Hi
Its impossible to guess at with no code or pictures.
If i do the same with Horz layout i get this