Skip to main content
added 7 characters in body; edited tags
Source Link
Nejat
  • 32.4k
  • 13
  • 109
  • 143

I'm having problems with my QTableViewQTableView and QItemDelegateQItemDelegate classes. For one column my delegate creates a simple combo box and everything works just fine. For my 2nd column I need a widget that has two combo boxes in a single widget.

I've written the following code in my QItemDelegateQItemDelegate, just to be clear this only shows code for my 2nd column, the one that doesn't work. The other simple ComboBoxCombo-box isn't shown as it works fine:

QWidget *UserDefinedUnitsDelegate::createEditor(QWidget *parent,const QStyleOptionViewItem & option ,const QModelIndex & index ) const
{
    //set up a simple widget with a layout
    QWidget* pWidget = new QWidget(parent);
    QHBoxLayout* hLayout = new QHBoxLayout(pWidget);
    pWidget->setLayout(hLayout);

    //add two combo boxes to the layout
    QComboBox* comboEditor = new QComboBox(pWidget);    
    QComboBox* comboEditor2 = new QComboBox(pWidget);   

    //now add both editors to this
    hLayout->addWidget(comboEditor);
    hLayout->addWidget(comboEditor2);
    return pWidget;
}

Now this displays just fine but when I edit it and click elsewhere it doesn't stop editing. Can anyone offer any pointers?

Edit: So i need to call CommitData() and closeEditor() at some point. Can anyone offer pointers on where to call these?

Thanks.

I'm having problems with my QTableView and QItemDelegate classes. For one column my delegate creates a simple combo box and everything works just fine. For my 2nd column I need a widget that has two combo boxes in a single widget.

I've written the following code in my QItemDelegate, just to be clear this only shows code for my 2nd column, the one that doesn't work. The other simple ComboBox isn't shown as it works fine:

QWidget *UserDefinedUnitsDelegate::createEditor(QWidget *parent,const QStyleOptionViewItem & option ,const QModelIndex & index ) const
{
    //set up a simple widget with a layout
    QWidget* pWidget = new QWidget(parent);
    QHBoxLayout* hLayout = new QHBoxLayout(pWidget);
    pWidget->setLayout(hLayout);

    //add two combo boxes to the layout
    QComboBox* comboEditor = new QComboBox(pWidget);    
    QComboBox* comboEditor2 = new QComboBox(pWidget);   

    //now add both editors to this
    hLayout->addWidget(comboEditor);
    hLayout->addWidget(comboEditor2);
    return pWidget;
}

Now this displays just fine but when I edit it and click elsewhere it doesn't stop editing. Can anyone offer any pointers?

Edit: So i need to call CommitData() and closeEditor() at some point. Can anyone offer pointers on where to call these?

Thanks.

I'm having problems with my QTableView and QItemDelegate classes. For one column my delegate creates a simple combo box and everything works just fine. For my 2nd column I need a widget that has two combo boxes in a single widget.

I've written the following code in my QItemDelegate, just to be clear this only shows code for my 2nd column, the one that doesn't work. The other simple Combo-box isn't shown as it works fine:

QWidget *UserDefinedUnitsDelegate::createEditor(QWidget *parent,const QStyleOptionViewItem & option ,const QModelIndex & index ) const
{
    //set up a simple widget with a layout
    QWidget* pWidget = new QWidget(parent);
    QHBoxLayout* hLayout = new QHBoxLayout(pWidget);
    pWidget->setLayout(hLayout);

    //add two combo boxes to the layout
    QComboBox* comboEditor = new QComboBox(pWidget);    
    QComboBox* comboEditor2 = new QComboBox(pWidget);   

    //now add both editors to this
    hLayout->addWidget(comboEditor);
    hLayout->addWidget(comboEditor2);
    return pWidget;
}

Now this displays just fine but when I edit it and click elsewhere it doesn't stop editing. Can anyone offer any pointers?

Edit: So i need to call CommitData() and closeEditor() at some point. Can anyone offer pointers on where to call these?

Thanks.

added 123 characters in body
Source Link

I'm having problems with my QTableView and QItemDelegate classes. For one column my delegate creates a simple combo box and everything works just fine. For my 2nd column I need a widget that has two combo boxes in a single widget.

I've written the following code in my QItemDelegate, just to be clear this only shows code for my 2nd column, the one that doesn't work. The other simple ComboBox isn't shown as it works fine:

QWidget *UserDefinedUnitsDelegate::createEditor(QWidget *parent,const QStyleOptionViewItem & option ,const QModelIndex & index ) const
{
    //set up a simple widget with a layout
    QWidget* pWidget = new QWidget(parent);
    QHBoxLayout* hLayout = new QHBoxLayout(pWidget);
    pWidget->setLayout(hLayout);

    //add two combo boxes to the layout
    QComboBox* comboEditor = new QComboBox(pWidget);    
    QComboBox* comboEditor2 = new QComboBox(pWidget);   

    //now add both editors to this
    hLayout->addWidget(comboEditor);
    hLayout->addWidget(comboEditor2);
    return pWidget;
}

Now this displays just fine but when I edit it and click elsewhere it doesn't stop editing. Can anyone offer any pointers?

Edit: So i need to call CommitData() and closeEditor() at some point. Can anyone offer pointers on where to call these?

Thanks.

I'm having problems with my QTableView and QItemDelegate classes. For one column my delegate creates a simple combo box and everything works just fine. For my 2nd column I need a widget that has two combo boxes in a single widget.

I've written the following code in my QItemDelegate, just to be clear this only shows code for my 2nd column, the one that doesn't work. The other simple ComboBox isn't shown as it works fine:

QWidget *UserDefinedUnitsDelegate::createEditor(QWidget *parent,const QStyleOptionViewItem & option ,const QModelIndex & index ) const
{
    //set up a simple widget with a layout
    QWidget* pWidget = new QWidget(parent);
    QHBoxLayout* hLayout = new QHBoxLayout(pWidget);
    pWidget->setLayout(hLayout);

    //add two combo boxes to the layout
    QComboBox* comboEditor = new QComboBox(pWidget);    
    QComboBox* comboEditor2 = new QComboBox(pWidget);   

    //now add both editors to this
    hLayout->addWidget(comboEditor);
    hLayout->addWidget(comboEditor2);
    return pWidget;
}

Now this displays just fine but when I edit it and click elsewhere it doesn't stop editing. Can anyone offer any pointers?

Thanks.

I'm having problems with my QTableView and QItemDelegate classes. For one column my delegate creates a simple combo box and everything works just fine. For my 2nd column I need a widget that has two combo boxes in a single widget.

I've written the following code in my QItemDelegate, just to be clear this only shows code for my 2nd column, the one that doesn't work. The other simple ComboBox isn't shown as it works fine:

QWidget *UserDefinedUnitsDelegate::createEditor(QWidget *parent,const QStyleOptionViewItem & option ,const QModelIndex & index ) const
{
    //set up a simple widget with a layout
    QWidget* pWidget = new QWidget(parent);
    QHBoxLayout* hLayout = new QHBoxLayout(pWidget);
    pWidget->setLayout(hLayout);

    //add two combo boxes to the layout
    QComboBox* comboEditor = new QComboBox(pWidget);    
    QComboBox* comboEditor2 = new QComboBox(pWidget);   

    //now add both editors to this
    hLayout->addWidget(comboEditor);
    hLayout->addWidget(comboEditor2);
    return pWidget;
}

Now this displays just fine but when I edit it and click elsewhere it doesn't stop editing. Can anyone offer any pointers?

Edit: So i need to call CommitData() and closeEditor() at some point. Can anyone offer pointers on where to call these?

Thanks.

added 140 characters in body
Source Link

I'm having problems with my QTableView and QItemDelegate classes. For one column my delegate creates a simple combo box and everything works just fine. For my 2nd column I need a widget that has two combo boxes in a single widget.

I've written the following code in my QItemDelegate, just to be clear this only shows code for my 2nd column, the one that doesn't work. The other simple ComboBox isn't shown as it works fine:

QWidget *UserDefinedUnitsDelegate::createEditor(QWidget *parent,const QStyleOptionViewItem & option ,const QModelIndex & index ) const
{
    //set up a simple widget with a layout
    QWidget* pWidget = new QWidget(parent);
    QHBoxLayout* hLayout = new QHBoxLayout(pWidget);
    pWidget->setLayout(hLayout);

    //add two combo boxes to the layout
    QComboBox* comboEditor = new QComboBox(pWidget);    
    QComboBox* comboEditor2 = new QComboBox(pWidget);   

    //now add both editors to this
    hLayout->addWidget(comboEditor);
    hLayout->addWidget(comboEditor2);
    return pWidget;
}

Now this displays just fine but when I edit it and click elsewhere it doesn't stop editing. Can anyone offer any pointers?

Thanks.

I'm having problems with my QTableView and QItemDelegate classes. For one column my delegate creates a simple combo box and everything works just fine. For my 2nd column I need a widget that has two combo boxes in a single widget.

I've written the following code in my QItemDelegate:

QWidget *UserDefinedUnitsDelegate::createEditor(QWidget *parent,const QStyleOptionViewItem & option ,const QModelIndex & index ) const
{
    //set up a simple widget with a layout
    QWidget* pWidget = new QWidget(parent);
    QHBoxLayout* hLayout = new QHBoxLayout(pWidget);
    pWidget->setLayout(hLayout);

    //add two combo boxes to the layout
    QComboBox* comboEditor = new QComboBox(pWidget);    
    QComboBox* comboEditor2 = new QComboBox(pWidget);   

    //now add both editors to this
    hLayout->addWidget(comboEditor);
    hLayout->addWidget(comboEditor2);
    return pWidget;
}

Now this displays just fine but when I edit it and click elsewhere it doesn't stop editing. Can anyone offer any pointers?

Thanks.

I'm having problems with my QTableView and QItemDelegate classes. For one column my delegate creates a simple combo box and everything works just fine. For my 2nd column I need a widget that has two combo boxes in a single widget.

I've written the following code in my QItemDelegate, just to be clear this only shows code for my 2nd column, the one that doesn't work. The other simple ComboBox isn't shown as it works fine:

QWidget *UserDefinedUnitsDelegate::createEditor(QWidget *parent,const QStyleOptionViewItem & option ,const QModelIndex & index ) const
{
    //set up a simple widget with a layout
    QWidget* pWidget = new QWidget(parent);
    QHBoxLayout* hLayout = new QHBoxLayout(pWidget);
    pWidget->setLayout(hLayout);

    //add two combo boxes to the layout
    QComboBox* comboEditor = new QComboBox(pWidget);    
    QComboBox* comboEditor2 = new QComboBox(pWidget);   

    //now add both editors to this
    hLayout->addWidget(comboEditor);
    hLayout->addWidget(comboEditor2);
    return pWidget;
}

Now this displays just fine but when I edit it and click elsewhere it doesn't stop editing. Can anyone offer any pointers?

Thanks.

updates to clarify QItemDelegate relationship.
Source Link
Loading
Source Link
Loading