Dropdown in Qtableview
-
And that on one specific cell ?
-
Then why not just position a QComboBox there and hide it once it has been used ?
-
Yes, since you only have that one combo box for that unique action.
-
hide the QCombobox how to do that?
And one issue when editing the combobox , new value in adding to new index?
how can I replace ?@n-2204 said in Dropdown in Qtableview:
hide the QCombobox how to do that?
-
@n-2204 said in Dropdown in Qtableview:
hide the QCombobox how to do that?
void QWidget::hide()
will hide the combobox from cell, and I have to show user the value of combobox selected by user like if combobox has 2 values when user selects a it is editable user can change it to t and if user selects b then its non editable and this value is set but if use hide then combobox will be hidden ? -
void QWidget::hide()
will hide the combobox from cell, and I have to show user the value of combobox selected by user like if combobox has 2 values when user selects a it is editable user can change it to t and if user selects b then its non editable and this value is set but if use hide then combobox will be hidden ?@n-2204 said in Dropdown in Qtableview:
if user selects b then its non editable and this value is set but if use hide then combobox will be hidden ?
Then show the selected value in a QLabel
-
@n-2204 said in Dropdown in Qtableview:
if user selects b then its non editable and this value is set but if use hide then combobox will be hidden ?
Then show the selected value in a QLabel
how to replace value in combobox?
testdropdown::testdropdown(QWidget *parent) : QMainWindow(parent) { ui.setupUi(this); QStandardItemModel* stndrditem_model1 = NULL; QComboBox* combobox1; QStringList lst; if (stndrditem_model1 == NULL) { stndrditem_model1 = new QStandardItemModel(10, 11, this);//row*col } ui.tableView->setModel(stndrditem_model1); ui.tableView->setColumnWidth(2, 1); const QModelIndex idx = stndrditem_model1 ->index(1, 1); combobox1 = qobject_cast<QComboBox*>(ui.tableView->indexWidget(idx)); if (!combobox1) { combobox1 = new QComboBox(); ui.tableView->setIndexWidget(idx, combobox1); } lst<< "test" << "testdata"; combobox1->addItems(lst); connect(combobox1, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &testdropdown::testedit); } void testdropdown::testedit(int indx) { if (indx == 1) { //when user select testdata combobox1->setEditable(true); //when user enter at index 1 the new data added at index 2 I want to replace at same index //how to replace testdata string list value with new value in combobox and index should remain same which is entered by user ?? } else{ combobox1->setEditable(false); } }