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 132 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 14 Sept 2020, 00:57 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);
    
    }
    
    J 1 Reply Last reply 14 Sept 2020, 09:36
    0
    • I Isidro Perla
      14 Sept 2020, 00:57

      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);
      
      }
      
      J Online
      J Online
      JonB
      wrote on 14 Sept 2020, 09:36 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

      1/2

      14 Sept 2020, 00:57

      • Login

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