I would imagine that the checkbox that you assign is trying to fill up the
full space given to it, and for some reason the space seem left-aligned.

If you were to composite the checkbox within another QWidget, put the
checkbox in a layout for the QWidget, and use
layout.setAlignment(Qt.AlignCenter | Qt.AlignCenter) the QWidget should
fill up the full space, whilst the checkbox should land in the center of
the QWidget. Don't forget to remove contentsMargins of the layout as well.
layout.setContentsMargins(0, 0, 0, 0)

A neat trick to debug these scenarios is to assign a temporary in-code
stylesheet.
my_widget.setObjectName('DebugTest')
my_widget.setStylesheet("#DebugTest {background-color: blue}")

Example delegate method:

checkbox = QCheckBox()
container = QWidget()
layout = QHBoxLayout(container)
layout.addWidget(checkbox)
layout.setAlignment(Qt.AlignCenter | Qt.AlignCenter)
layout.setContentsMargins(0, 0, 0, 0)
# Here is where you return your container, rather than the checkbox
directly.
return container

*Edit*: After having actually looked at the example you posted, this is the
way he does it too. :)



On 19 February 2014 11:30, Ricardo Viana <[email protected]> wrote:

>
> <https://lh3.googleusercontent.com/-jr_XjoiXbTI/UwSVwsYwbxI/AAAAAAAABX4/HM1M1Dp5Oqg/s1600/Lister.png>
>
> Hi again. back with some more questions!!
> i have fixed a few things and got the alignment right (textAlign actually),
> but the checkBoxes don´t align.
>
> https://gist.github.com/RicardoViana/8961047
>
> i followed this link, it seems to be a workaround
>
> http://www.qtcentre.org/threads/19157-QTableView-checkbox-center-with-stylesheet?p=181413#post181413
> but its C++ and i loose myself a bit in there since i don´t know c++.
> Has anyone got it working in Python/PyQT/Pyside ? I guess the same
> principles apply.
>
> thanks guys
> best
> Ricardo
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Python Programming for Autodesk Maya" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/python_inside_maya/4df653a3-fb21-405a-b329-681e74a8692e%40googlegroups.com
> .
>
> For more options, visit https://groups.google.com/groups/opt_out.
>



-- 
*Marcus Ottosson*
[email protected]

-- 
You received this message because you are subscribed to the Google Groups 
"Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/CAFRtmOBsj9YhDponJxanS%2B31tC6%2BpMhTbh_t-b7xXosk%2B7PWNQ%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to