I have a simple QAbstractTableModel and set it as the model for a
QTableView.  However, I see every cell as a checkbox in it beside the
text.  This is unusual for me as I usually have to request it in the
flags method (in pyqt and C++).  However, reimplementing the flags
method and explicitly skipping the ItemCheckable flag, I still get
checkboxes in my cells.  I can catch the CheckStateRole in data and
return a check state, but I don't want any checks at all.  Where are
those checks being specified?

    public HandleListModel(Object obj, String[] handleInfo) {
        super();
        props = handleInfo;
    }
    public int rowCount(QModelIndex parent) {
        return props.length;
    }
    public int columnCount(QModelIndex parent) {
        return 2;
    }
    public Object data(QModelIndex index, int role) {
        int row = index.row();
        int column = index.column();

        if (role == Qt.ItemDataRole.DisplayRole) {
            if (column == 0)
                return props[row].split(":")[1];
            else
                return "ack";
        } else if (role == Qt.ItemDataRole.CheckStateRole) {
            return Qt.CheckState.Checked;
        } else
            return new QVariant();
    }
    public Qt.ItemFlags flags(QModelIndex index) {

        return new Qt.ItemFlags(new Qt.ItemFlag[]{Qt.ItemFlag.ItemIsEnabled,
                    Qt.ItemFlag.ItemIsSelectable});
    }
_______________________________________________
Qt-jambi-interest mailing list
[email protected]
http://lists.trolltech.com/mailman/listinfo/qt-jambi-interest

Reply via email to