Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Block input in cell setCellWidget Combobox



  • 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 code

    while(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);
    
    }


  • @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?


Log in to reply