Testing the table model/view

Helge Fredriksen hf at poseidon.no
Wed Feb 13 23:07:22 CET 2008


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?

Regards,
Helge Fredriksen

Eskil Abrahamsen Blomfeldt wrote:
> Eskil Abrahamsen Blomfeldt wrote:
>> It is not the default to render checkboxes, your model is most likely 
>> returning some invalid data for the decoration role of the cell.
>
> Sorry, I have to correct myself here. The problem is not returning the 
> wrong thing for the decoration role, but for the 
> Qt.ItemDataRole.CheckStateRole. If you return anything except null for 
> this role then the cell will get a check box (which is unchecked 
> unless the object returned is the boolean value true or a value which 
> is converted to "true", such as the integer value 1 or the string "1" 
> etc.)
>
>
> -- Eskil
>



More information about the Qt-jambi-interest mailing list