Centering a CheckBox in a GridLayout
-
Hi,
maybe there's something obvious, that I am missing, but after searching the web for quite some time, I haven't been able to find an answer to this. As the title of my post suggests I want to achieve something rather simple, i.e., I'd like to have QCheckBox instance without text horizontally centered in the middle of a GridLayout.I found some hints regarding QStyleSheet, but couldn't find any really useful description of how to proceed to reach my goal.
Kind regards,
Andreas
-
@andi456 Use three columns for the TextLabel, put the checkBox in the center one.
-
@Christian-Ehrlicher You mean, a textlabel spanning over three columns, right? Ok, I think that will do trick.
Anyway, I just wonder, why there's no checkbox/radiobutton without a label attached to it.
-
@andi456 said in Centering a CheckBox in a GridLayout:
Anyway, I just wonder, why there's no checkbox/radiobutton without a label attached to it.
Because nobody forces you to actually put text there?! :)
If you want to center the checkBox within its own cell and not put it in the center of the whole GridLayout, what I initially thought you are trying to do, then @mpergand 's solution will do exactly this.The code for it would look like this:
gridLayout->setAlignment(yourCheckBox, Qt::AlignHCenter);
-