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. How can i get in the QTableWidget the value from selected row and column?
Forum Updated to NodeBB v4.3 + New Features

How can i get in the QTableWidget the value from selected row and column?

Scheduled Pinned Locked Moved General and Desktop
6 Posts 4 Posters 21.0k Views 2 Watching
  • 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.
  • A Offline
    A Offline
    Adrianos
    wrote on 16 Mar 2015, 13:06 last edited by Adrianos
    #1
    This post is deleted!
    K 1 Reply Last reply 16 Mar 2015, 16:55
    0
    • A Adrianos
      16 Mar 2015, 13:06

      This post is deleted!

      K Offline
      K Offline
      koahnig
      wrote on 16 Mar 2015, 16:55 last edited by koahnig
      #2

      The question is if you know already the row and column upfront?
      If yes, there is no need of using the signal slot mechanism, since you know already which element you like to access.
      You should use item method
      If you want to click on an item and know which one this is, cellActivated or cellClicked signals may be a choice.

      Vote the answer(s) that helped you to solve your issue(s)

      A 1 Reply Last reply 17 Mar 2015, 10:45
      3
      • D Offline
        D Offline
        dheerendra
        Qt Champions 2022
        wrote on 16 Mar 2015, 17:06 last edited by
        #3

        If you want to get the values of selected items, you can use selectedItems() API and get the QListWidgetItem list. From this list you can fetch QListWidgetItem one-by-one and get QListWidgetItem.
        QList<QTableWidgetItem *> list = selectedItems();
        for(each i item in list) {
        QTableWidgetItem *item = list.at(i)
        qDebug() << item.text()
        }

        Dheerendra
        @Community Service
        Certified Qt Specialist
        http://www.pthinks.com

        1 Reply Last reply
        5
        • K koahnig
          16 Mar 2015, 16:55

          The question is if you know already the row and column upfront?
          If yes, there is no need of using the signal slot mechanism, since you know already which element you like to access.
          You should use item method
          If you want to click on an item and know which one this is, cellActivated or cellClicked signals may be a choice.

          A Offline
          A Offline
          Adrianos
          wrote on 17 Mar 2015, 10:45 last edited by Adrianos
          #4
          This post is deleted!
          K 1 Reply Last reply 17 Mar 2015, 13:20
          0
          • A Adrianos
            17 Mar 2015, 10:45

            This post is deleted!

            K Offline
            K Offline
            koahnig
            wrote on 17 Mar 2015, 13:20 last edited by
            #5

            @Adrianos
            Try to call update(). This is inherited from QWidget.

            void ParamTableWidget::cellValue(int ro, int col)
            {
            qDebug()<<"Hello World";
            update();
            }

            Vote the answer(s) that helped you to solve your issue(s)

            1 Reply Last reply
            0
            • H Offline
              H Offline
              Hasan Vaez
              wrote on 5 Apr 2018, 17:33 last edited by Hasan Vaez 4 Jun 2018, 11:56
              #6

              Simple Example:

              QString SelectedRow;
              int col = 0;//Column
              int row = 0;//Selected Row
              SelectedRow = ui->MYQTableViewWidget->selectedItems().at(row)->data(col).toString();

              Change col for getting other Columns data.
              Change row for getting other selected Rows data.

              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