[Interest] How to center the check box.

Andre Somers andre at familiesomers.nl
Sun Dec 29 15:57:52 CET 2013


william.crocker at analog.com schreef op 29-12-2013 15:25:
> Gang:
>
> I have a QTableView which uses a custom
> model based on QAbstractItemModel.
> The model sets the Qt::ItemIsUserCheckable flag
> for one of the columns and the model data()
> function responds to the Qt::CheckStateRole
> for the same column. The result is a working
> check box in the corresponding column of the
> table view.
>
>              This is all good.
>
> My problem is that the check box is presented
> flush left in the column and I would like
> it to be centered. The closest I could find was
> Qt::TextAlignmentRole which didn't sound right
> or have any affect.
>
> Any help would be appreciated.
>
There is no easy way to make the check box appear aligned differently. 
The only way I know of, is to create your own delegate and do the 
rendering yourself (using QStyle to do the hard work, of course).

André




More information about the Interest mailing list