remove space around qToolButton
-
@mrjj
Ah, I think you misinterpreted what I mean, I've hand coded all the buttons and didn't use a ui file.
So I want to try replicate your button that i saw in the image using code. -
@Bonnie
Thanks for the suggestion, it works in a way, but once the button is highlighted you can still see the border around the QIcon in the QToolButton. So the size of the button is still the same, I was hoping to shrink the size of the button, to being much closer to the size of the QIcon which is 16x16. I would prefer to have maybe 1/2 pixel border around the button. But also allow the button to expand if the screen resolution/ screen size is high. -
@Bonnie
Thanks for the suggestion, it works in a way, but once the button is highlighted you can still see the border around the QIcon in the QToolButton. So the size of the button is still the same, I was hoping to shrink the size of the button, to being much closer to the size of the QIcon which is 16x16. I would prefer to have maybe 1/2 pixel border around the button. But also allow the button to expand if the screen resolution/ screen size is high.@jkwok678 said in remove space around qToolButton:
But also allow the button to expand if the screen resolution/ screen size is high.
Ok then DONT use setFixedSize to set size but just the normal ones
-
@jkwok678
Yes i fairly sure i did :)
its
button1->setFixedSize(100,100);
button1->setIconSize(QSize(100, 100));for 100x100 icon / button
-
@mrjj
With this implementation is the setFixedSize more of a default/intitial size?
So when I have code that allows the button to resize, it can still do so?@jkwok678 said in remove space around qToolButton:
setFixedSize
Will set to a fixed size so nope, it wont resize then
so dont use it if you want toolbuttons to grow -
So, what could I do to have the button have the same size as the QIcon, or at least just less blank space?
-
Would it be able to do that and also expand?As in when the button expands the Icon could expand as well? Or perhaps switch to a different Icon that us higher resolution?
Hi
Sadly no.
If you want such things, make a custom button that does it.However, Qt has support for HIRES displays that do scaling etc.
and QIcon can have hires version to be used on such displays
https://doc.qt.io/qt-5/highdpi.htmlbut this has nothing to do with you want icon to cover all of the button at all times :)
That is not a hires thing, in my opinion :)here is example of custom button
https://stackoverflow.com/questions/31742194/dynamically-resize-qicon-without-calling-setsizeiconIt scales the cion to fit at any given time.
As you can see its not much code.