Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Increase space between text and checkbox in Qt

Tags:

c++

qt

qcheckbox

If you set a fixed checkbox size, the text will be aligned to the checkbox itself. With the standard layout direction, the text will start right after the box, and with right-to-left layout it will end right before the box, just like this (the border is just the widget's border to indicate the widget/s real size, don't be confused):

Is there a way to align the text to the other side to achieve this:

enter image description here

like image 646
SingerOfTheFall Avatar asked Sep 26 '12 07:09

SingerOfTheFall


1 Answers

As you mentioned you have a fixed size QCheckBox. So easily without subclassing you can get to your desire QCheckBox using style sheets. But unfortunately text-align property just works for QPushButton and QProgressBar. But the alternate stylesheet that you can use is :

QCheckBox{
spacing:100px;
}

With RightToLeft direction for your QCheckBox and this style sheet your checkbox is ready! :) . Change spacing according to your application.
Hope this helps.
here is my output

like image 58
s4eed Avatar answered Oct 10 '22 13:10

s4eed