I have implemented my own (very simple though) QStandardItemModel-qtableview.
#ifndef PARAMETERMODEL_H
#define PARAMETERMODEL_H
#include <QtGui>
#include <QtSql/QSqlTableModel>
#include <QtSql/QSqlRelationalDelegate>
#include <QtSql/QSqlQuery>
#include <QMessageBox>
#include <QComboBox>
#include <QWidget>
#include <comboboxDelegates.h>
#include <spinboxdelegates.h>
class ParameterModel
: public QWidget{
Q_OBJECT
public:
ParameterModel
( QWidget *parent
= 0);
public slots:
void addNewRow();
void addNewRow2();
void deleteRow(int);
private:
ActionComboBoxDelegate *actionComboBoxDelegate;
TypeComboBoxDelegate *typeComboBoxDelegate;
StatusComboBoxDelegate *statusComboBoxDelegate;
VrotSpinBoxDelegate *vrotSpinBoxDelegate;
SigmaSpinBoxDelegate *sigmaSpinBoxDelegate;
GammaSpinBoxDelegate *gammaSpinBoxDelegate;
XiSpinBoxDelegate *xiSpinBoxDelegate;
SemitSpinBoxDelegate *semitSpinBoxDelegate;
DlradSpinBoxDelegate *dlradSpinBoxDelegate;
LlabSpinBoxDelegate *llabSpinBoxDelegate;
AWSpinBoxDelegate *aWSpinBoxDelegate;
EiSpinBoxDelegate *eiSpinBoxDelegate;
};
#endif // PARAMETERMODEL_H
#ifndef PARAMETERMODEL_H
#define PARAMETERMODEL_H
#include <QtGui>
#include <QtSql/QSqlTableModel>
#include <QtSql/QSqlRelationalDelegate>
#include <QtSql/QSqlQuery>
#include <QMessageBox>
#include <QComboBox>
#include <QWidget>
#include <comboboxDelegates.h>
#include <spinboxdelegates.h>
class ParameterModel : public QWidget
{
Q_OBJECT
public:
ParameterModel( QWidget *parent = 0);
QStandardItemModel* model;
QTableView* tableView;
public slots:
void addNewRow();
void addNewRow2();
void deleteRow(int);
private:
QVBoxLayout* vboxlayout;
ActionComboBoxDelegate *actionComboBoxDelegate;
TypeComboBoxDelegate *typeComboBoxDelegate;
StatusComboBoxDelegate *statusComboBoxDelegate;
VrotSpinBoxDelegate *vrotSpinBoxDelegate;
SigmaSpinBoxDelegate *sigmaSpinBoxDelegate;
GammaSpinBoxDelegate *gammaSpinBoxDelegate;
XiSpinBoxDelegate *xiSpinBoxDelegate;
SemitSpinBoxDelegate *semitSpinBoxDelegate;
DlradSpinBoxDelegate *dlradSpinBoxDelegate;
LlabSpinBoxDelegate *llabSpinBoxDelegate;
AWSpinBoxDelegate *aWSpinBoxDelegate;
EiSpinBoxDelegate *eiSpinBoxDelegate;
};
#endif // PARAMETERMODEL_H
To copy to clipboard, switch view to plain text mode
I usually need 3-5 of these, which I append them to a QVector
QVector<ParameterModel*>* modelVector;
QVector<ParameterModel*>* modelVector;
To copy to clipboard, switch view to plain text mode
My problem is that when I am trying to set the data to the items, it gets slow
QElapsedTimer t;
t.start();
if ( column_index < 4 )
modelVector->at(model_index)->model->item(row_index,column_index)->setData(line);
qDebug()<<t.elapsed();
t.start();
if ( column_index > 4 )
modelVector->at(model_index)->model->item(row_index,column_index)->setData(line.toDouble());
qDebug()<<t.elapsed();
QElapsedTimer t;
t.start();
if ( column_index < 4 )
modelVector->at(model_index)->model->item(row_index,column_index)->setData(line);
qDebug()<<t.elapsed();
t.start();
if ( column_index > 4 )
modelVector->at(model_index)->model->item(row_index,column_index)->setData(line.toDouble());
qDebug()<<t.elapsed();
To copy to clipboard, switch view to plain text mode
The timers here give values 500-600. The strange thing is that the output is usually like this (I run it multiple times)
0
593
....
577
0
....
562
0
etc,etc.
What can I do to make it faster?
Bookmarks