PDA

View Full Version : how to resize the square of a qcheckbox?



eric_vi
4th September 2009, 22:24
i want my app to have a few checkboxes with a size of 12x12... but i cannot manage to get the check box to go under 16x16...

how can you do that?

wysota
4th September 2009, 22:39
Reimplement QStyle::pixelMetric() for QStyle::PM_IndicatorWidth and QStyle::PM_IndicatorHeight.

eric_vi
4th September 2009, 23:41
yes this works,

but i do not want all my checkboxes all over my application to be resized i just want them to be resized just inside a couple of dialogs...

what should i do in this case?

wysota
5th September 2009, 00:17
Apply your style only on those checkboxes you want modified. Or subclass QCheckBox and draw the indicators yourself, of course.

eric_vi
5th September 2009, 01:27
so my question is how do you restrict a style to a checkbox or else, i have no clue how to do that.. i have it to work for the whole app

wysota
5th September 2009, 01:59
QWidget::setStyle()

eric_vi
5th September 2009, 22:36
i am still fighting with that... as a style applied to a widget i do not get it to resize like whenthe style is global... i have no clue why... also it is a pretty heavy implementation even if it works

i am trying also as a style sheet which is the way i would much more prefer (!) with indicator-height : 12 px, just within qt-designer, but it does not resize either, is there anything else i can try or i need to add

wysota
6th September 2009, 08:54
What does not resize?

eric_vi
6th September 2009, 15:36
the little square of the checkbox, or if it is a radio button , the circle of the radio button.. they seem not to be able to change size at all

wysota
6th September 2009, 16:25
Can you prepare a minimal compilable example reproducing the problem? I mean the one when using QWidget::setStyle() doesn't yield the desired effect.

eric_vi
6th September 2009, 21:36
to a QCheckbox, i use designer... right click, style sheet, i add...

QCheckBox::indicator {
width: 10px;
height: 10px;
}

this does not resize the checkbox square in Mac Aqua style, it works in Plastique mode

wysota
6th September 2009, 23:31
I meant using QWidget::setStyle()... Most stylesheets in general won't work with Aqua style.