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. Table Widget selected item doesnt take the first one
Forum Updated to NodeBB v4.3 + New Features

Table Widget selected item doesnt take the first one

Scheduled Pinned Locked Moved Unsolved General and Desktop
table widgetqt4
2 Posts 2 Posters 467 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.
  • D Offline
    D Offline
    deleted286
    wrote on last edited by deleted286
    #1

    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
    JonBJ 1 Reply Last reply
    0
    • D deleted286

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

      @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();
      
      1 Reply Last reply
      0

      • Login

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