Block input in cell setCellWidget Combobox
-
wrote on 14 Sept 2020, 00:57 last edited by
Hello I need to know how can I block my combobox in my qtableWidget, I only want to show the current index in a Demo mode,
then I need to block the inputs inside qtablewidget combobox via setCellWidget , here´s my current codewhile(consultar.next()){
ui->tW_Datos->insertRow(fila); ui->tW_Datos->setItem(fila, 0, new QTableWidgetItem(consultar.value(2).toByteArray().constData())); ui->tW_Datos->setItem(fila, 1, new QTableWidgetItem(consultar.value(3).toByteArray().constData())); QComboBox *combo; combo = new QComboBox; combo->addItems({"", "Simple", "Media", "Alta"}); combo->setProperty("row", ui->tW_Datos->rowCount() - 1); combo->setProperty("column", 0); combo->setCurrentText(consultar.value(3).toByteArray().constData()); connect(combo, SIGNAL(currentIndexChanged(const QString&)), this, SLOT(OnComboIndexChanged(const QString&))); ui->tW_Datos->setCellWidget(fila, 1, combo); }
-
Hello I need to know how can I block my combobox in my qtableWidget, I only want to show the current index in a Demo mode,
then I need to block the inputs inside qtablewidget combobox via setCellWidget , here´s my current codewhile(consultar.next()){
ui->tW_Datos->insertRow(fila); ui->tW_Datos->setItem(fila, 0, new QTableWidgetItem(consultar.value(2).toByteArray().constData())); ui->tW_Datos->setItem(fila, 1, new QTableWidgetItem(consultar.value(3).toByteArray().constData())); QComboBox *combo; combo = new QComboBox; combo->addItems({"", "Simple", "Media", "Alta"}); combo->setProperty("row", ui->tW_Datos->rowCount() - 1); combo->setProperty("column", 0); combo->setCurrentText(consultar.value(3).toByteArray().constData()); connect(combo, SIGNAL(currentIndexChanged(const QString&)), this, SLOT(OnComboIndexChanged(const QString&))); ui->tW_Datos->setCellWidget(fila, 1, combo); }
wrote on 14 Sept 2020, 09:36 last edited by JonB@Isidro-Perla
What does "block my combobox" mean to you? Disable it? Make it so it only shows the items it has in it and does not allow the user to type in their own item? Something else?
1/2