Hi,
I'm using QAbstractTableModel/QTableView to display a table of numeric data stored as strings that have been cast to QVariant--that is, in a vector<QVariant> in my QAbstractTableModel subclass. When I show the data, in every cell there is a checkbox in tri-state mode--checked when the value is 2, darkened when it is 1, and empty otherwise.
In no place did I (explicitly) 'ask' for this checkbox, I just want to display the data in the cell all by itself. Here is the code I use to set the QTableView properties:
(DataTable is a QWidget, saTableModel is my QAbstractTableModel subclass)
DataTable
::DataTable(QWidget* parent, saTableModel
* _satm
) : QWidget(parent
), satm
(_satm
){
layMain->addWidget(tblv);
setLayout(layMain);
SetUpTableView();
tblv->setHorizontalHeader(hdrv);
tblv->show();
}
void DataTable::SetUpTableView()
{
tblv->setModel(satm);
tblv->setAlternatingRowColors(true);
tblv->setSelectionModel(select);
}
DataTable::DataTable(QWidget* parent, saTableModel* _satm) : QWidget(parent), satm(_satm)
{
QVBoxLayout* layMain = new QVBoxLayout;
tblv = new QTableView(this);
layMain->addWidget(tblv);
setLayout(layMain);
SetUpTableView();
hdrv = new QHeaderView(Qt::Horizontal,tblv);
tblv->setHorizontalHeader(hdrv);
hdrv->resizeSections(QHeaderView::ResizeToContents);
tblv->show();
}
void DataTable::SetUpTableView()
{
tblv->setModel(satm);
tblv->setEditTriggers(QAbstractItemView::NoEditTriggers);
tblv->setAlternatingRowColors(true);
QItemSelectionModel* select = new QItemSelectionModel(satm);
tblv->setSelectionModel(select);
tblv->setSelectionBehavior(QAbstractItemView::SelectRows);
}
To copy to clipboard, switch view to plain text mode
Anybody know why I'm getting unwanted checkboxes?
Best,
Matt
Bookmarks