[Qt-interest] setTextAlignment API in QT-3.3.6 ???
Andre Somers
andre at familiesomers.nl
Thu Oct 14 07:58:05 CEST 2010
Op 13-10-2010 17:10, Nishant Sharma schreef:
> Hi,
> In QTable class, I was looking for an API that sets the text
> alignment. But, there is no such set API. There's only a API to get
> that setting:
> virtual int alignment() const.
>
> setTextAlignment is available in QT-4.6 : void
> QTableWidgetItem::setTextAlignment ( int alignment )
>
> Can someone suggest how to achieve the same in QT-3.3.6.
> My table is read-only.
First of all: please upgrade to a recent Qt version. Qt 3.3 is seriously
OLD, deprecated, unmainted, etc. Don't use it for new code, and
seriously considder porting to Qt 4 for existing apps.
You can subclass your QTableItem and reimplement alignment(). You could
add a setAlignment method that takes a Qt::AlignmentFlags. Let the base
implementation handle alignment if it is Qt::AlignAuto (and make that
the default), and use your set value otherwise. That should, if memory
serves me well, get you what you want. If not, then you also need to do
your painting yourself, wich can be done by reimplementing the paint()
method. QTableItem has so many virtual methods for a reason: it is
intended to be subclassed.
André
More information about the Qt-interest-old
mailing list