[Qt-interest] Show QTableView is a very slow?
SALOMEHER at terra.es
SALOMEHER at terra.es
Tue Feb 3 16:06:40 CET 2009
I have a class
class MiTabla: public QTableView
MiTabla(QWidget *parent):QTableView(parent) { ... }
void mousePressEvent(QMouseEvent *event) { ... }
void keyPressEvent(QKeyEvent *event) { ... }
I then in my code initializes
MiTabla *view = new MiTabla(principal);
view->setGeometry(1, 0, principal->width()-1, PanLeyenda->y()-2));
TablaModelI *model = new TablaModelI(0, MatrizMicroDatosS, listaH,
listaV);
view->setModel(model);
MatrizMicroDatosS is QString **
listaH and listaV is QStringList
TablaModelI is class TablaModelI: public QAbstractTableModel
TablaModelI::TablaModelI(QObject *parent, QString ** &vec, QStringList
&cabecH, QStringList &cabecV):QAbstractTableModel(parent)
{
distances = vec;
cabeceraH = cabecH;
cabeceraV = cabecV;
}
where I in
QVariant data(const QModelIndex &index, int role) { ... }
I paint each cell of a different color depending on the value you
have.
QVariant TablaModelI::data(const QModelIndex &index, int role) const
{
if (!index.isValid())
return QVariant();
if (role == Qt::TextAlignmentRole)
return int(Qt::AlignCenter);
if (role == Qt::DisplayRole)
return distances[index.row()][index.column()];
if (role == Qt::BackgroundRole) {
QColor color;
if (index.column() == 0)
return QColor(Qt::green);
if (ConjuntoRegistrosExcluidos.contains(index.row())) {
color = Qt::red;
color.setRgb(255, 144, 16);
color.setHsv (32, 239, 255);
return QColor(color);
}
if (VectorExclusionVariables[index.column()-1]) {
color = Qt::red;
color.setRgb(255, 144, 16);
color.setHsv (32, 239, 255);
return QColor(color);
}
if (ConjuntoRegistrosIncorrectos.contains(index.row())) {
if ((VariablesAImputar[index.row()].contains(index.column()
-1)) && (!FmeVariablesAsociadas->EsVariableImputable(index.column()
-1)))
return QColor(Qt::magenta);
return QColor(Qt::red);
}
if (MatrizImputacion[index.row()][index.column()-1]) return
QColor(Qt::yellow);
if (ConjuntoRegistrosDonantes.contains(index.row())) {
color = Qt::cyan;
color.setRgb(87, 205, 255);
color.setHsv (198, 168, 255);
return QColor(color);
}else return QColor(Qt::white);
}
return QVariant();
}
Could this be the reason why so late?
----Mensaje original----
De: aberaud at infflux.com
Recibido: 03/02/2009 15:32
Para: <qt-interest at trolltech.com>
Asunto: Re: [Qt-interest] Show QTableView is a very slow?
Hi,
We can't give you any answer without some more information. Did you
derive the QTableView class ? Do you have big calculations in its
showEvent() ? Do you use a QItemDelegate with a heavy paintEvent() ?
Did
you connect the
tab change to one or several slots ?
Regards,
Alex
SALOMEHER at terra.es a écrit :
> Hi,
> I have an application that displays a number of Tab of a
QTabWidget.
> Each Tab has a QTableView whose model is a huge matrix. When I go on
a
> Tab to display this takes a lot, why is this so? may be because the
> view has many colors?
>
> Regards.
>
>
> *Ahora también puedes acceder a tu correo Terra desde el móvil.*
> *Infórmate pinchando*** aquí.**
> <http://ad.doubleclick.net/clk;77451406;6134080;d?http://www.correo.
movistar.es/do/isp/assistant/login?isp=terra>
>
------------------------------------------------------------------------
>
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
>
--
BERAUD Alexandre
Ingénieur Développement
Infflux - Informatique & Flux
Tel: 01 49 57 92 00 - Fax : 01 49 57 92 01
Mail: aberaud at infflux.com
Visitez notre site : www.infflux.com
_______________________________________________
Qt-interest mailing list
Qt-interest at trolltech.com
http://lists.trolltech.com/mailman/listinfo/qt-interest
Ahora también puedes acceder a tu correo Terra desde el móvil.
Infórmate pinchando aquí.
More information about the Qt-interest-old
mailing list