Qt World Summit: Register Today!

Help with setting value in QStyledItemDelegate combobox

  • I want to programaticlly set the value(display text) of a QStandardItem. The QTable uses QStyledItemDelegate which makes use of QComboBox in the createEditor method to offer a drop down selection( Note: items do not have the same list of items in their edit->combobox). Based on certain actions of my program I would like to set the index from the QStyleItemDelegate->editor's->QComboBox.

    So I guess my question is - how would I set the value to say index 1 of the combobox for a QStandardItem.

    Hope this is easy to do. Any suggestions very much appreciated

  • Lifetime Qt Champion


    What kind of action would that be to modify your QComboBox's index ?

  • Hi and thanks for taking the time to inquire. First it is actually a QTreeView I am using and not a QTableView (my mistake). I have a copy button in the toolbar and the idea is to copy one item in the tree, so I want to walk the source item and all of its children and its children, etc. I have no problem making the items but when it comes to setting the values where an item is a combox box is my question.

    Sorry for the double post with my question, I thought this thread was deleted when that nutcase hijacked my thread with his crusade against Digia

  • Lifetime Qt Champion

    Don't worry about your threads, only his posts get deleted.

    Then next question, were does the data from your combo box come from ? If I understand your correctly, the content of the combo box should be the current value stored in the model when you start editing ?

Log in to reply