[Qt-interest] QTableWidget: how to make read-only certain columns

Malyushytsky, Alex alex at wai.com
Mon Apr 6 19:46:47 CEST 2009


Subclass QItemDelegate, override

        QWidget *createEditor( QWidget *parent,
                          const QStyleOptionViewItem &option,
                          const QModelIndex &index) const;

Make it return null.


Then set it for column:

->setItemDelegateForColumn ( 1, _delegate );

If it is QTableWidget make sure it is not read only for other columns to be editable.
This approach works for any QabstractItemView derived class.

Regards,
   Alex

________________________________________
From: qt-interest-bounces at trolltech.com [mailto:qt-interest-bounces at trolltech.com] On Behalf Of Miguel Cardenas
Sent: Sunday, April 05, 2009 11:44 AM
To: qt-interest
Subject: [Qt-interest] QTableWidget: how to make read-only certain columns

Hello list

One question, is it possible to make read-only certain columns in a QTableWidget? Didn't find something like this in the documentation...

Thanks

--
Miguel Cardenas


---------------------------------------------------------------------------------------------------
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