Results 1 to 1 of 1

Thread: QAbstractTableModel, QTableView and restoreState.

  1. #1
    Join Date
    Jun 2008
    Location
    Rome, Italy
    Posts
    95
    Thanks
    19
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default QAbstractTableModel, QTableView and restoreState.

    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.

    Qt Code:
    1. #ifndef CARTMODEL_H
    2. #define CARTMODEL_H
    3.  
    4. #include <QtWidgets>
    5. #include "ItemsCart.h"
    6.  
    7. class ItemsCart;
    8.  
    9. class CartModel : public QAbstractTableModel
    10. {
    11. Q_OBJECT
    12.  
    13. public:
    14. CartModel(QObject *parent);
    15.  
    16. void setCart(ItemsCart *inItemsCart);
    17.  
    18. int rowCount(const QModelIndex &parent = QModelIndex()) const ;
    19.  
    20. int columnCount(const QModelIndex &parent = QModelIndex()) const;
    21.  
    22. QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
    23.  
    24. QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
    25.  
    26. protected:
    27. ItemsCart *mItemsCart;
    28. };
    29.  
    30. #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
    Last edited by cydside; 10th August 2014 at 11:46. Reason: spelling corrections

Similar Threads

  1. Replies: 0
    Last Post: 8th May 2012, 22:09
  2. Replies: 0
    Last Post: 5th April 2011, 16:51
  3. Replies: 4
    Last Post: 6th May 2009, 08:18
  4. Performance with QTableView and QAbstractTableModel
    By MBex in forum Qt Programming
    Replies: 3
    Last Post: 25th February 2009, 08:04
  5. Replies: 3
    Last Post: 29th January 2009, 08:38

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.