Dear All
We have a QSqlRelationalTableModel, and we would like to make a column read-only? Is there any example codes that could help us?
Thanks!
AEK
Dear All
We have a QSqlRelationalTableModel, and we would like to make a column read-only? Is there any example codes that could help us?
Thanks!
AEK
Subclass the model and reimplement the flags() method to not return Qt::ItemIsEditable for items in the first column.
Could you please help us a little with a example! We are a bit new to QT
Qt Code:
public: if(index.column()!=0) } };To copy to clipboard, switch view to plain text mode
Let me explain more in our .h we call relationaltable below,
QSqlRelationalTableModel *model = new QSqlRelationalTableModel;
model->setTable("stokdakiler");
model->setFilter("stokid = " + Stokid);
model->setEditStrategy(QSqlRelationalTableModel::OnField Change);
model->setRelation(2, QSqlRelation("marka", "markaid", "marka"));
model->setRelation(4, QSqlRelation("birimler", "birimid", "birim"));
model->select();
table->setModel(model);
table->resizeColumnsToContents ();
table->resizeRowsToContents ();
table->setColumnHidden (0, true);
table->setColumnHidden (1, true);
table->setItemDelegate(new QSqlRelationalDelegate(tablestokda));
table->setSortingEnabled (true);
And after this what should we do?
You should substitute all occurences to QSqlRelationalTableModel with "MyModel" (based on the code I have given you - if you change the class name, change it here as well).
aekilic (28th May 2007)
Build it..
other crude sample....
http://www.qtcentre.org/forum/f-qt-s...dmin-6807.html
aekilic (28th May 2007)
Thank you very much both of you, we were able to solve the problem easly!
Bookmarks