I've gone through the older threads about this subject but didn't find anything regarding my problem at hand:

So I'm creating a QTableWidget which has some of its columns using a custom delegate which returns a QComboBox editor. My problem is that I cannot get it to work in all situations.

For example, I have my own ExcelDlg Dialog and in its constructor I create a QTableWidget and set it to using my delegate.

Like this:
Qt Code:
  1. QStringList values;
  2. values
  3. << "DESC"
  4. << "POS"
  5. << "ABNORMAL INTERRUPTION"
  6. << "TESTI VAAN"
  7. << "VIELÄ YKS";
  8.  
  9. cDropdownTableWidgetItemDelegate delegate;
  10. delegate.setValues(values);
  11.  
  12. QTableWidget *table = new QTableWidget(2,3,this);
  13. table->setItemDelegate(&delegate);
  14.  
  15. lo = new QHBoxLayout();
  16. lo->addWidget(table);
To copy to clipboard, switch view to plain text mode 
Unfortunately the result is an empty table, no cells of any kind, only horizontal and vertical header items are displayed correctly.

But when I use it in a newly created dialog, for example:
Qt Code:
  1. QStringList values;
  2. values
  3. << "DESC"
  4. << "POS"
  5. << "ABNORMAL INTERRUPTION"
  6. << "TESTI VAAN"
  7. << "VIELÄ YKS";
  8.  
  9. cDropdownTableWidgetItemDelegate delegate;
  10. delegate.setValues(values);
  11.  
  12. QDialog *dlg = new QDialog();
  13.  
  14. QTableWidget *table = new QTableWidget(2,3,dlg);
  15. table->setItemDelegate(&delegate);
  16.  
  17. dlg->exec();
To copy to clipboard, switch view to plain text mode 

It works fine. What is happening? Why is it not working in the upper example?

If needed, i can post the code to my delegate.