Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Update non-editable QTableView with QAbstractTableModel
Forum Updated to NodeBB v4.3 + New Features

Update non-editable QTableView with QAbstractTableModel

Scheduled Pinned Locked Moved General and Desktop
3 Posts 3 Posters 920 Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    Lars_-.
    wrote on last edited by
    #1

    How to update QTableView when my model changes? My QTableView is non editable, so afaik i dont have/want to reimplement setData(...).
    How do i update it, after my internal data changes?

    class myTableModel : public QAbstractTableModel
    {
    ...
    	void SetMyData(MyDataType* myData)
    	{
    		m_myData = myData;
    		emit QAbstractItemModel::dataChanged(index(0, 0), index(myData->rows(),myData->Cols()));
    	}
    ...
    }
    

    Doesn't work, neither tableView->update() does.

    thanks for help

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Since you are replacing your underlying data, I'd rather go with modelReset

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • A Offline
        A Offline
        alex_malyu
        wrote on last edited by
        #3

        problem is that index(myData->rows(),myData->Cols())
        is not a valid index

        it should be
        index(myData->rows()-1,myData->Cols()-1)
        if functions are named correctly

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved