You are not logged in.

1

Wednesday, May 11th 2005, 7:44am

How to align no cell of a table left aligned?

Hi,

I have a table widget , and some of the table cells have nos like 1000, 5000, etc,

These no are getting right aligned and other texts are getting left aligned


I have tried some thing like this , But doesn't work

QString no("5000");
QString t = no.leftJustify( 5, ' ' );
tableCommon->setText(9, 1, t);

Please help


Thanks in advance,

zlatko

Professional

  • "zlatko" is male

Posts: 728

Location: Ukraine,Lviv

Occupation: programmer

  • Send private message

2

Wednesday, May 11th 2005, 9:55am

Quoted

int QTableItem::alignment () const [virtual]
The alignment function returns how the text contents of the cell are aligned when drawn. The default implementation aligns numbers to the right and any other text to the left.


try reinplement it
a life without programming its alike empty bottle 8)

3

Wednesday, May 11th 2005, 11:31am

Hi ,

I have tried like this, But this also doesn't work, Please let me know if there is anything wrong in the code

QTableItem* item = new QTableItem(tCommon,QTableItem::Never);
item->setText("5000");
item->AlignLeft;
tCommon->setItem(9,1,item);


Thanks.

dimitri

Professional

  • "dimitri" is male

Posts: 1,311

Occupation: Engineer

  • Send private message

4

Wednesday, May 11th 2005, 12:48pm

Quoted

Originally posted by Raghav
Hi ,

I have tried like this, But this also doesn't work,


How doesn't it work? Could you maybe show some code?

Quoted

QTableItem* item = new QTableItem(tCommon,QTableItem::Never);
item->setText("5000");
item->AlignLeft;
tCommon->setItem(9,1,item);


This doesn't even compile, does it?

zlatko

Professional

  • "zlatko" is male

Posts: 728

Location: Ukraine,Lviv

Occupation: programmer

  • Send private message

5

Wednesday, May 11th 2005, 1:42pm

You must create own class like

Source code

1
2
3
4
5
6
7
8
9
10
QMyTableItem :  public QTableItem
..............


// and then reinplement next method

int QMyTableItem::alignment() const
{  
    return Qt::AlignLeft;
}
a life without programming its alike empty bottle 8)