[Qt-interest] Text alignment
Paul Colby
qt at colby.id.au
Tue Nov 3 10:47:44 CET 2009
The problem, essentially, is that the way you are adding new items
from the list *replaces* the original items, but you are only setting
the alignment on the original items - not the new replacement items.
So, either re-set the alignment when adding the new items, or update
existing items instead of adding new ones...
For example, to re-set the alignment when adding new items:
> for(int col = 0; col < 4; col++)
> {
> QTableWidgetItem *item = new QTableWidgetItem(list[col]);
> item->setTextAlignment(Qt::AlignHCenter); // This line in new :)
> tableWidget->setItem(row, col, item);
> }
Alternatively, update the existing items rather than replacing them. eg:
> for(int col = 0; col < 4; col++)
> {
> //QTableWidgetItem *item = new QTableWidgetItem(list[col]);
> //tableWidget->setItem(row, col, item);
> tableItem[row][column]->setText(list[col]); // Update the existing item's text.
> }
I hope that helps ;)
pc.
--
http://colby.id.au
More information about the Qt-interest-old
mailing list