0

I have a tableview (model) with 5 columns. In one of them, I want to show 2 options in a combobox. The options are predetermined, so I think that the use of delegate is not necessary. Am I wrong?

for (int state=0; state <3; state++)
{
    QStandardItem item = new QStandardItem();
    item.setEditable( false );
    item.setTextAlignment( Qt.AlignmentFlag.AlignCenter );

    switch (state)
    {
        case 0: 
            item.setText( "Column 0" );
            item.setEditable( true );
            break;
        case 1:
            item.setText( "Column 1" );
            item.setEditable( true );
            break;
        case 2:
            //create a new combobox
            break;
    }
}
Mat
  • 202,337
  • 40
  • 393
  • 406

1 Answers1

0

I think you have to (or at least you should) use a delegate. The delegate is the object what connects the view (tableview is basically a layout and retrieves it's content via model+delegate) with the model. The model is not (it shouldn't) responsible for how it's content will be presented. That's the role of the delegate - it 'transforms' the data (model) to a presentable entity when the view asks it to do it. The model cannot (and should not) declare a view for it's data.

Viktor Benei
  • 3,447
  • 2
  • 28
  • 37