Hello,
I've got a little problem with QTableView and my own model subclassed from QAbstractTableView. The model is read only, user can change/add data using external dialog. When I add some data, table has still the same number of rows and new data doesn't appear. I know the data is correctly added. When I remove some data from a model, number of rows doesn't change either, last rows of the table just becomes empty. Here is header of my model:
Q_OBJECT
public:
EmployeesTableModel
( QObject* parent
= 0 );
QVariant headerData
(int section, Qt
::Orientation orientation,
int role
= Qt
::DisplayRole) const;
void setEmployeesList( std::vector<WPEmployee>* employees );
private:
std::vector<WPEmployee>* _employees;
};
class EmployeesTableModel : public QAbstractTableModel {
Q_OBJECT
public:
EmployeesTableModel( QObject* parent = 0 );
int rowCount(const QModelIndex &parent = QModelIndex()) const;
int columnCount ( const QModelIndex & parent = QModelIndex() ) const;
QVariant data(const QModelIndex &index, int role) const;
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
void setEmployeesList( std::vector<WPEmployee>* employees );
private:
std::vector<WPEmployee>* _employees;
};
To copy to clipboard, switch view to plain text mode
thanks for any help
Bookmarks