[Qt-interest] Text alignment

Tony Rietwyk tony.rietwyk at rightsoft.com.au
Thu Nov 5 01:23:03 CET 2009


Hi Phil, 

What happens when you step through the copy constructor of the item?  I
assume that the alignment is not being copied for some reason.  

Hope that helps, 

Tony.



> -----Original Message-----
> From: qt-interest-bounces at trolltech.com 
> [mailto:qt-interest-bounces at trolltech.com] On Behalf Of Phil
> Sent: Tuesday, 3 November 2009 16:09
> To: qt-interest at trolltech.com
> Subject: [Qt-interest] Text alignment
> 
> 
> Thank you for reading this.
> 
> This is a problem that I have struggled with for some time. A 
> search of the 
> archives shows that this question has been asked before but I 
> cannot relate 
> the answers to my particular application.
> 
> The following code first fills a 6 x 4 table with "x" after 
> which I fill the 
> table one row at a time from a list. The code works correctly 
> except that the 
> cell contents are left justified no matter what alignment type I use.
> 
> This is how I initialise the table.
> 
> for(int row = 0; row < 6; row++)
> {
>   for(int column = 0; column < 4; column++)
>   {
>     tableItem[row][column] = new QTableWidgetItem("x");
>     tableItem[row][column]->setTextAlignment(Qt::AlignHCenter);
>   }
> }
> 
> This is how I add the items from a QStringList list.
> 
> for(int col = 0; col < 4; col++)
> {
>   QTableWidgetItem *item = new QTableWidgetItem(list[col]);
>   tableWidget->setItem(row, col, item);
> }
> 
> Can anyone see where I've gone wrong?
>  
> -- 
> Regards,
> Phil




More information about the Qt-interest-old mailing list