views:

322

answers:

2

I'm just getting started with Qt programming, and I'm trying to make a simple tabular data layout using a QTableView control with a model class of my own creation inheriting from QAbstractTableModel. For some reason, my table view ends up looking like this:

alt text

What in the heck are those things that look like checkboxes (but don't do anything when I click them) in every cell, and how do I make them go away? I haven't changed any of the QTableView properties except for the object's name.

If it matters, my model code is dead simple:

MyTableModel::MyTableModel(QObject* parent)
  : QAbstractTableModel(parent)
{
}

MyTableModel::~MyTableModel()
{
}

int MyTableModel::rowCount(const QModelIndex& parent) const
{
  return 1000; 
}

int MyTableModel::columnCount(const QModelIndex& parent) const
{
  return 5;
}

QVariant MyTableModel::data(const QModelIndex& index, int role) const
{
  return "Foo";
}

The dialog UI is built in Qt Designer, and inside the class for the dialog I attach the model to the view like this:

MyTableModel testModel = new MyTableModel(this);
ui.testTable->setModel(testModel);

Other than that I perform no operations on ui.testTable.

Using Qt 4.6.

A: 

Do you by any chance happen to set the Qt::ItemIsUserCheckable flag in flags()?

Marcus Lindblom
No, and even if I override `flags` to return ` QAbstractTableModel::flags(index) `, the checkboxes remain.
Tyler McHenry
+6  A: 
Elrohir
Perfect! Thank you. I suppose I shouldn't just be ignoring parameters that I haven't learned about yet...
Tyler McHenry
Glad to help you :) Qt simply rocks!
Elrohir