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

Table Widget selected item doesnt take the first one



  • Here is the code script that i take the selected ones

    ```
    QList<QTableWidgetItem*> MySelList = ui->tableWidget->selectedItems();
      for (QTableWidgetItem* item : MySelList)
      {
    
    
        double TheText = item->text().toDouble();
     qDebug() << TheText;
    
    
    But it doesnt take the first one that i select
    
    
    ![a.png](https://ddgobkiprc33d.cloudfront.net/8f7d8fde-de35-4be0-8dbc-998f0267cb72.png) 
    
    This give me the output like :
    
    0.56
    0.58


  • @suslucoder said in Table Widget selected item doesnt take the first one:

    But it doesnt take the first one that i select

    Yes, this code will visit all selected items, including whatever "first one" which you say it does not include. Else everybody would be complaining about it.

    Why don't you print out:

    qDebug() << ui->tableWidget->selectedItems().length();
    

Log in to reply