I am getting a very strange problem in my application and it's driving me nuts

I am using a QTableView with a custom model derived from QAbstractTableModel. I also have a separate QTableView which is used only to display the header and 1 row. This table view uses QStandardItemModel.

Now, when i run my application, the CPU usage jumps up to > 90% immediately and remains that way all the time. I tried finding the reason for this by commenting out stuff.

Now, if i comment the tableView->setModel() line, the CPU usage is fine but as soon as i uncomment it, CPU usage jumps up > 90%.

I commented all code which was using my custom model to check if the high CPU usage was because of my model class but it doesn't seem the case.

As i mentioned above, i have another QTableView and it uses the QStandardItemModel to display a header and single row. This is the code for the header table:

Qt Code:
  1.  
  2. // Table Headers
  3. model->setHeaderData(0, Qt::Horizontal, QString("Column1");
  4. model->setHeaderData(1, Qt::Horizontal, QString("Column2");
  5.  
  6. // Set the header table model
  7. m_pHeaderTableView->setModel(model);
To copy to clipboard, switch view to plain text mode 
Now, if i comment all code which uses my custom model and use only the header table with QStandardItemModel, the above code works fine and CPU usage is ok but when i set the column widths using the following:

Qt Code:
  1. m_pHeaderTableView->setColumnWidth(0, 50);
  2. m_pHeaderTableView->setColumnWidth(1, 50);
To copy to clipboard, switch view to plain text mode 

When i use setColumnWidth and run my application, the CPU usage is > 90% all the time. If i comment setColumnWidth, CPU usage is fine.

So, in the above case, i am not using my custom model at all. I am using a simple QTableView with QStandardItemModel.

I tried to do the same thing with the other table view which uses my custom model and commenting out setColumnWidth makes no difference to the CPU usage, it remains high all the time.

So, i am not able to find out why my application is using > 90% CPU all the time. If i comment setModel calls in both QTableViews the CPU usage drops to normal but offcourse i can't live without setModel.