[Qt-interest] How to show the word in the center of a Tableview's cell?

Malyushytsky, Alex alex at wai.com
Sat Apr 4 04:40:47 CEST 2009


The easiest way probably will be:

Subclass  QAbstractTableModel
Override data():

..........
if (role == Qt::TextAlignmentRole )
{
        return Qt::AlignHCenter;
}
else
 QAbstractTableModel:: data( role )
..............

Have not tested it, but should work.

Hope this helps,
   Alex



-----Original Message-----
From: qt-interest-bounces at trolltech.com [mailto:qt-interest-bounces at trolltech.com] On Behalf Of Kermit Mei
Sent: Friday, April 03, 2009 4:52 PM
To: Qt-interest
Subject: [Qt-interest] How to show the word in the center of a Tableview's cell?

Hello, I use QTableView tow show some words from a mode. But how can I
make the words be showed in the center of the cells? I can't find the
corresponding method.

They now always show from the left by default.

Now is
_________________
|hello      |
-----------------

I want:
_________________
|   hello   |
-----------------

Thanks;p

_______________________________________________
Qt-interest mailing list
Qt-interest at trolltech.com
http://lists.trolltech.com/mailman/listinfo/qt-interest


---------------------------------------------------------------------------------------------------
Weidlinger Associates, Inc. made the following annotations.

"This message and any attachments are solely for the intended recipient and may contain confidential or privileged information. If you are not the intended recipient, any disclosure, copying, use, or distribution of the information included in this message and any attachments is prohibited. If you have received this communication in error, please notify us by reply e-mail and immediately and permanently delete this message and any attachments. Thank you."

"Please consider our environment before printing this email."




More information about the Qt-interest-old mailing list