Aki-Matti
4th March 2008, 12:53
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:
QStringList values;
values
<< "DESC"
<< "POS"
<< "ABNORMAL INTERRUPTION"
<< "TESTI VAAN"
<< "VIELÄ YKS";
cDropdownTableWidgetItemDelegate delegate;
delegate.setValues(values);
QTableWidget *table = new QTableWidget(2,3,this);
table->setItemDelegate(&delegate);
lo = new QHBoxLayout();
lo->addWidget(table);
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:
QStringList values;
values
<< "DESC"
<< "POS"
<< "ABNORMAL INTERRUPTION"
<< "TESTI VAAN"
<< "VIELÄ YKS";
cDropdownTableWidgetItemDelegate delegate;
delegate.setValues(values);
QDialog *dlg = new QDialog();
QTableWidget *table = new QTableWidget(2,3,dlg);
table->setItemDelegate(&delegate);
dlg->exec();
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.
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:
QStringList values;
values
<< "DESC"
<< "POS"
<< "ABNORMAL INTERRUPTION"
<< "TESTI VAAN"
<< "VIELÄ YKS";
cDropdownTableWidgetItemDelegate delegate;
delegate.setValues(values);
QTableWidget *table = new QTableWidget(2,3,this);
table->setItemDelegate(&delegate);
lo = new QHBoxLayout();
lo->addWidget(table);
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:
QStringList values;
values
<< "DESC"
<< "POS"
<< "ABNORMAL INTERRUPTION"
<< "TESTI VAAN"
<< "VIELÄ YKS";
cDropdownTableWidgetItemDelegate delegate;
delegate.setValues(values);
QDialog *dlg = new QDialog();
QTableWidget *table = new QTableWidget(2,3,dlg);
table->setItemDelegate(&delegate);
dlg->exec();
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.