Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Block input in cell setCellWidget Combobox
Forum Updated to NodeBB v4.3 + New Features

Block input in cell setCellWidget Combobox

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 140 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • I Offline
    I Offline
    Isidro Perla
    wrote on last edited by
    #1

    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);
    
    }
    
    JonBJ 1 Reply Last reply
    0
    • I Isidro Perla

      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);
      
      }
      
      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by JonB
      #2

      @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 Reply Last reply
      1

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved