Hi to all,
I used to save the QTableView horizontalHeader through saveState() and restore it by restoreState(...toByteArray()).
The model usually associated is a QSqlQueryModel. Now my QTableView is filled with a custom model inherited from QAbstractTableModel.
#ifndef CARTMODEL_H
#define CARTMODEL_H
#include <QtWidgets>
#include "ItemsCart.h"
class ItemsCart;
{
Q_OBJECT
public:
void setCart(ItemsCart *inItemsCart);
QVariant headerData
(int section, Qt
::Orientation orientation,
int role
= Qt
::DisplayRole) const;
protected:
ItemsCart *mItemsCart;
};
#endif
#ifndef CARTMODEL_H
#define CARTMODEL_H
#include <QtWidgets>
#include "ItemsCart.h"
class ItemsCart;
class CartModel : public QAbstractTableModel
{
Q_OBJECT
public:
CartModel(QObject *parent);
void setCart(ItemsCart *inItemsCart);
int rowCount(const QModelIndex &parent = QModelIndex()) const ;
int columnCount(const QModelIndex &parent = QModelIndex()) const;
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
protected:
ItemsCart *mItemsCart;
};
#endif
To copy to clipboard, switch view to plain text mode
The problem I have is that restoreState() restore nothing, instead clears or hides all the horizontal headers.
Should I miss a function to reimplement?
Thanks in advance,
Danilo
Bookmarks