Hello,
I have QTableView and i fill it with checkbox widget's.
But widgets are alignment to right side. I want alignment to middle.Code:
tableView->setIndexWidget (index,editor); //index is QModelIndex();
How can I set this?
Printable View
I highly recommend you to get rid of expensive index widgets and make the items checkable instead. This is done by returning Qt::ItemIsUserCheckable amongst other flags in your model's flags() implementation. You can adjust text alignment by returning a suitable value for Qt::TextAlignmentRole in model's data() implementation.
I did that by adding widget to layout, and for layout set TextAligment flag.. It works..
Just be aware that Qt's model-view framework has built-in support for checkable items. It is considered as a mistake to abuse QComboBoxes for that. The view has put quite a lot of effort to keeping index widgets in correct places, over corresponding items. I hope you don't have too many items because it will be a resource hog..