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?

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 20.9k 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.
  • A Offline
    A Offline
    Adrianos
    wrote on last edited by Adrianos
    #1
    This post is deleted!
    K 1 Reply Last reply
    0
    • A Adrianos

      This post is deleted!

      K Offline
      K Offline
      koahnig
      wrote on 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
      3
      • dheerendraD Offline
        dheerendraD Offline
        dheerendra
        Qt Champions 2022
        wrote on 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

          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 last edited by Adrianos
          #4
          This post is deleted!
          K 1 Reply Last reply
          0
          • A Adrianos

            This post is deleted!

            K Offline
            K Offline
            koahnig
            wrote on 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
            • Hasan VaezH Offline
              Hasan VaezH Offline
              Hasan Vaez
              wrote on last edited by Hasan Vaez
              #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