Performance with QTableView and QAbstractTableModel
Hello,
At the moment i am developing an apllication for displaying database contents by QTableView and QAbstractTableModel.
For this purpose i wrote a test application to check the performance. I set only 200 rows and 37 columns but the whole applications slows a bit down. Additionaly the selection of cells is relatively slow.
Is there any way to increase the performance of this test application?
Test.h
Code:
{
Q_OBJECT
public:
Model();
virtual int rowCount
( const QModelIndex &parent
) const;
virtual int columnCount
(const QModelIndex &parent
) const;
int section,
Qt::Orientation orientation,
int role) const;
};
{
Q_OBJECT
public:
private:
Model m_model;
};
Test.cpp
Code:
Model::Model()
{
}
//
//-----------------------------------------------------------------------------
{
return 200;
}
//
//-----------------------------------------------------------------------------
int Model
::columnCount(const QModelIndex &parent
) const {
return 37;
}
//
//-----------------------------------------------------------------------------
{
if (role == Qt::DisplayRole)
{
.arg(index.row())
.arg(index.column()));
}
}
//
//-----------------------------------------------------------------------------
int section,
Qt::Orientation orientation,
int role) const
{
if (section < 37)
else
}
//
//-----------------------------------------------------------------------------
m_view(this)
{
setCentralWidget(&m_view);
m_view.setModel(&m_model);
m_view.verticalHeader()->setDefaultSectionSize(17);
}
I hope someone can help me.
Thanks in advance.
regards Marco B.
Re: Performance with QTableView and QAbstractTableModel
setUniformRowHeights(true) on the view will speed things up.
side note: you should check role in headerData(), too.
Re: Performance with QTableView and QAbstractTableModel
doesnt that work only for QTreeView?
Re: Performance with QTableView and QAbstractTableModel
I read from the Qt Assistant that setUniformRowHeights(true) is only available on QTreeViews.
Looks like there is no way of speeding up my application :(.