allign text in TableView
-
Hi, I have Tableview connected to a SqlTableModel and all the column are left aligned, numeric don't show the 2 digits if they are 00.
First i will like to understand if this is due to the MySql connector or the field definition on the DB,
Second how can I correct this ?
Thanks a lot -
@saulos
This has nothing to do with field definitions in the database or the connector.See https://doc.qt.io/qt-5/qabstractitemmodel.html#data and https://doc.qt.io/qt-5/qt.html#ItemDataRole-enum for the
Qt::TextAlignmentRole
role. For number output format control, you are intended to create a https://doc.qt.io/qt-5/qstyleditemdelegate.html for your view. -
@saulos You must use a delegate (QStyledItemDelegate) to correct how that information is displayed, for example override displayText().