Qt-jambi-interest Archive, September 2007
Alignment problem with table
Message 1 in thread
Hi,
I wrote a TableModel which is derived from QAbstractTableModel. The
model works fine and all data is shown in the corresponding QTableView.
Now I want to change the alignment of several columns so I added the
following lines of code to the data() method:
if (role == Qt.ItemDataRole.TextAlignmentRole)
{
return Qt.AlignmentFlag.AlignRight;
}
Unfortunately it changes nothing. Is there anything else I have to do to
get my data aligned to the right side of each cell?
Regards,
Andreas
Message 2 in thread
Hi Andreas,
I tested the code you described and found the same problem. It looks like the
enum is not converted to an int when arriving on the c++ side.
A workaround for this problem is:
if (role == Qt.ItemDataRole.TextAlignmentRole) {
return 2;
// return Qt.AlignmentFlag.AlignRight;
}
This is of course a bug, and we will fix it. Thanks for reporting the
problem. :-)
Regards,
HÃvard FrÃiland
On Wednesday 12 September 2007 16:56, Andreas Heck wrote:
> Hi,
>
> I wrote a TableModel which is derived from QAbstractTableModel. The
> model works fine and all data is shown in the corresponding QTableView.
> Now I want to change the alignment of several columns so I added the
> following lines of code to the data() method:
>
>
> if (role == Qt.ItemDataRole.TextAlignmentRole)
> {
> return Qt.AlignmentFlag.AlignRight;
> }
>
> Unfortunately it changes nothing. Is there anything else I have to do to
> get my data aligned to the right side of each cell?
>
>
> Regards,
>
> Andreas