Aligner une colonne QTableView à droite
Bonjour,
Je suis novice en programmation QT, et j'essaie depuis un certain temps de regler ce problème mais je n'y arrive pas et je suis vraiment bloqué c'est pourquoi je viens vers vous pour m'aider
j'ai un Qtableview dans Logista.cpp que je remplis comme ca :
Code:
1 2 3 4 5 6 7 8 9 10
| QSqlQueryModel * modalStockRec= new QSqlQueryModel();
QSqlQuery QryTabStockRec;
QryTabStockRec.exec("select codvar 'Variété',CAST(sum(pdsfru) as signed integer) as 'Tout-Venant', \
if(frigo='N' and deverdi='N' and etat='R', cast(sum(pdsfru) as signed integer) ,0) as Arrivage, \
if(frigo='O' and deverdi='N' and etat='F', cast(sum(pdsfru) as signed integer) ,0) as Frigo, \
if(frigo='N' and deverdi='O' and etat='F', cast(sum(pdsfru) as signed integer),0) as Deverdissage, \
if((frigo='O' or deverdi='O') and etat='R', cast(sum(pdsfru) as signed integer),0 ) as Ressuyage \
from palbrut where numver=0 group by 1;");
modalStockRec->setQuery(QryTabStockRec);
ui->TabStockRec->setModel(modalStockRec); |
j'ai crée une classe pour pouvoir aligner le tableau :
stylingproxymodel.h
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
| #ifndef STYLINGPROXYMODEL_H
#define STYLINGPROXYMODEL_H
#include <QObject>
#include <QIdentityProxyModel>
#include <QModelIndex>
#include <QObject>
class StylingProxyModel : public QIdentityProxyModel
{
QVariant data(const QModelIndex &index, int role) const
{
if (role != Qt::TextAlignmentRole)
return QIdentityProxyModel::data(index, role);
return Qt::AlignCenter;
}
public :
StylingProxyModel();
};
#endif // STYLINGPROXYMODEL_H |
stylingproxymodel.cpp
Code:
1 2 3 4 5 6
| #include "stylingproxymodel.h"
StylingProxyModel::StylingProxyModel()
{
} |
maintenant je ne sais pas comment lier entre cette classe et le QTableView
Aidez moi S'il vous plait
Merci d'avance