Testing the table model/view
Gunnar Sletta
gunnar at trolltech.com
Thu Feb 14 08:58:58 CET 2008
Helge Fredriksen wrote:
> Ok, that's nice, I have a working model/view table that can
> edit/remove/add rows. Easier to work with than the Swing equivalent, no
> doubt!
>
> However, upon removing rows, I have to make the cells selectable first.
> overriding the model with
>
> public Qt.ItemFlags flags(QModelIndex index) {
> return Qt.ItemFlag.createQFlags(Qt.ItemFlag.ItemIsEditable,
> Qt.ItemFlag.ItemIsEnabled, Qt.ItemFlag.ItemIsSelectable);
> }
>
> This makes it possible to select several cells at once, something that
> is not desired since I then need to sort out which rows are multiple
> selected via possible multiple column on the same row being selected.
>
> How can I set the model to be single selection mode, which is possible
> in Swing tables/lists?
Hi Helge,
What you're looking for is selection behaviour and selection modes which
are properties of the view:
http://doc.trolltech.com/qtjambi-4.3.3_01/com/trolltech/qt/gui/QAbstractItemView.html#setSelectionBehavior(com.trolltech.qt.gui.QAbstractItemView.SelectionBehavior)
http://doc.trolltech.com/qtjambi-4.3.3_01/com/trolltech/qt/gui/QAbstractItemView.html#setSelectionMode(com.trolltech.qt.gui.QAbstractItemView.SelectionMode)
best regards,
Gunnar
More information about the Qt-jambi-interest
mailing list