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 488 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 19 Mar 2021, 14:33 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
    J 1 Reply Last reply 19 Mar 2021, 15:15
    0
    • D deleted286
      19 Mar 2021, 14:33

      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
      J Offline
      J Offline
      JonB
      wrote on 19 Mar 2021, 15:15 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

      1/2

      19 Mar 2021, 14:33

      • 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