QTableView has unwanted checkboxes in every cell

QTableView has unwanted checkboxes in every cell

Asked on January 8, 2019 in Qt.
Add Comment


  • 2 Answer(s)

    QTableView  and checkboxes in every cell:

    MyTableModel::data()  using the.

    QVariant MyTableModel::data(const QModelIndex& index, int role) const
    {
        if (role == Qt::DisplayRole)
            return "foo";
        else
            return QVariant();
    }
    

    By returning the  QVariant  to act the Qt::CheckStateRole was  mistaken by the QTableView.

    Answered on January 8, 2019.
    Add Comment

    Try changing MyTableModel::data() to the following:

    QVariant MyTableModel::data(const QModelIndex& index, int role) const
    {
        if (role == Qt::DisplayRole)
            return "foo";
        else
            return QVariant();
    }
    Answered on March 5, 2019.
    Add Comment


  • Your Answer

    By posting your answer, you agree to the privacy policy and terms of service.