Text alignment in QTableWidget object
-
wrote on 11 Feb 2022, 16:27 last edited by
Hi all,
I'm a beginner in Python QT and I'm struggling with an apparent simple problem: I would need to align the text of an item loaded from a MySQL table into a QTableWidget object. I searched the web but I couldn't find any solution.
Can you help me ?
Thanks in advance -
Hi all,
I'm a beginner in Python QT and I'm struggling with an apparent simple problem: I would need to align the text of an item loaded from a MySQL table into a QTableWidget object. I searched the web but I couldn't find any solution.
Can you help me ?
Thanks in advancewrote on 11 Feb 2022, 16:39 last edited by JonB 2 Nov 2022, 16:39@Achab61
AQTableWidget
's items areQTableWidgetItem
s. And that has QTableWidgetItem::setTextAlignment().Having said that,
QTableWidget
is not the optimal widget to show data from SQL database tables, because it has its own model, you will be copying things between the SQL data model and theQTableWidget
. At some stage you might want to consider moving to aQTableView
which can display data from the SQL model. -
@Achab61
AQTableWidget
's items areQTableWidgetItem
s. And that has QTableWidgetItem::setTextAlignment().Having said that,
QTableWidget
is not the optimal widget to show data from SQL database tables, because it has its own model, you will be copying things between the SQL data model and theQTableWidget
. At some stage you might want to consider moving to aQTableView
which can display data from the SQL model. -
@Achab61
AQTableWidget
's items areQTableWidgetItem
s. And that has QTableWidgetItem::setTextAlignment().Having said that,
QTableWidget
is not the optimal widget to show data from SQL database tables, because it has its own model, you will be copying things between the SQL data model and theQTableWidget
. At some stage you might want to consider moving to aQTableView
which can display data from the SQL model. -
@JonB Would you mind provide with an example about how it looks like the statement for the setTextAlignment in Python ?
1/5