Using the Spin Box Delegate Example, I was able to create a more complex delegate system that included QDateTime, QLineEdit, and QComboBox for the columns. My class works perfectly when I use the example main.cpp from the spinbox delegate example.

I made a window in designer with a QTableView in it, and attempted to apply the the model and delegate to it as follows:

Qt Code:
  1. //setup interface of main window:
  2. DialogAddInventoryMass::DialogAddInventoryMass(QWidget *parent, QSqlDatabase db) : QDialog(parent) {
  3.  
  4. setupUi(this);
  5.  
  6. QStandardItemModel model(10, 9);
  7. inventoryDelegate delegate;
  8.  
  9. tableView->setModel(&model);
  10. tableView->setItemDelegate(&delegate);
  11.  
  12.  
  13.  
  14. //connect form item signals to slots that arent in the UI file here:
  15. connect(buttonBox, SIGNAL(accepted()), this, SLOT(returnVars()));
  16. connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
  17.  
  18. database = db;
  19. }
To copy to clipboard, switch view to plain text mode 

What I expected to see (as I did using the spin box example main.cpp) would be my QTableView with 10 rows, and 9 columns, and the delegate working properly.

What actually happens, is a blank QTableView, no rows/columns in it, and there are no errors (either in compilation or runtime). I also have cell borders enabled in the .ui file and console enabled.

What might the reason be that the QStandardItemModel is not applied to the QTableView in my UI?