[Qt-interest] header Data of Tree Model is Read-Only??
Tony Rietwyk
tony.rietwyk at rightsoft.com.au
Wed May 27 05:47:59 CEST 2009
Hi Bin,
The flags() only applies to the cells, not the headers. Note that the
header related routines use 'int section' parameters, not model indexes. So
none of the model index routines apply, and probably the delegate, as well.
I think that internally, the headers are implemented using their own view?
Maybe you can use that? Have a look at QHeaderView.
Hope that helps,
I implemented the following functions, but it still no work for me...
Did I missing something ??
-----------------------
Editable Items
Editable models allow items of data to be modified, and may also provide
functions to allow rows and columns to be inserted and removed. To enable
editing, the following functions must be implemented correctly:
flags() <http://doc.trolltech.com/4.5/qabstractitemmodel.html#flags>
Must return an appropriate combination of flags for each item. In
particular, the value returned by this function must include
Qt::ItemIsEditable <http://doc.trolltech.com/4.5/qt.html#ItemFlag-enum> in
addition to the values applied to items in a read-only model.
setData() <http://doc.trolltech.com/4.5/qabstractitemmodel.html#setData>
Used to modify the item of data associated with a specified model index. To
be able to accept user input, provided by user interface elements, this
function must handle data associated with Qt::EditRole
<http://doc.trolltech.com/4.5/qt.html#ItemDataRole-enum> . The
implementation may also accept data associated with many different kinds of
roles specified by Qt::ItemDataRole
<http://doc.trolltech.com/4.5/qt.html#ItemDataRole-enum> . After changing
the item of data, models must emit the dataChanged()
<http://doc.trolltech.com/4.5/qabstractitemmodel.html#dataChanged> signal
to inform other components of the change.
setHeaderData()
<http://doc.trolltech.com/4.5/qabstractitemmodel.html#setHeaderData>
Used to modify horizontal and vertical header information. After changing
the item of data, models must emit the headerDataChanged()
<http://doc.trolltech.com/4.5/qabstractitemmodel.html#headerDataChanged>
signal to inform other components of the change.
--------------------------
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090527/601a21bf/attachment.html
More information about the Qt-interest-old
mailing list