QTableView readonly columns....
-
Hi ,
I am developing an enterprise application using NokiaQT SDK. I have used Sqlite DB and Qtableview for showing data in forms and to edit tha data via UI. My problem is I want to make one or two columns readonly.
Can you please give solution with out subclassing QTableView because I have derived class from QWidget and using QTableview as a member.
-
have a look at
@setItemDelegateForColumn ( int column, QAbstractItemDelegate * delegate )@
You will need a readonly delegate. There is an example on how to do this :
read the whitepaper "Qt 4's Model/View Delegates"
You will find the link to download "here":http://www.qtrac.eu/marksummerfield.html
Have fun
-
Indeed, use the flags method. You can either do that by subclassing the actual model, or by using a proxy model that just overrides the flags method to return the correct flags. There is an, perhaps already usuable, "example":http://developer.qt.nokia.com/wiki/QSortFilterProxyModel_subclass_for_readonly_columns_columns_with_checkboxes_and_password_columns on how to do this on the wiki. The class presented there can already make columns read only.