Example #1
0
    @Override
    public void setEditorData(QWidget editor, QModelIndex index) {
      QComboBox comboBox = (QComboBox) editor;
      if (comboBox == null) return;

      int pos = comboBox.findText((String) index.model().data(index), Qt.MatchFlag.MatchExactly);
      comboBox.setCurrentIndex(pos);
    }
Example #2
0
    @Override
    public QWidget createEditor(QWidget parent, QStyleOptionViewItem option, QModelIndex index) {
      QComboBox comboBox = new QComboBox(parent);
      if (index.column() == 1) {
        comboBox.addItem(tr("Normal"));
        comboBox.addItem(tr("Active"));
        comboBox.addItem(tr("Disabled"));
        comboBox.addItem(tr("Selected"));
      } else if (index.column() == 2) {
        comboBox.addItem(tr("Off"));
        comboBox.addItem(tr("On"));
      }

      comboBox.activated.connect(this, "emitCommitData()");

      return comboBox;
    }