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. Get Text from QTableWidget in spesific row and colum

Get Text from QTableWidget in spesific row and colum

Scheduled Pinned Locked Moved General and Desktop
5 Posts 2 Posters 28.8k Views 1 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.
  • E Offline
    E Offline
    eyesBird
    wrote on last edited by
    #1

    Hi All,
    I have a QTableWidget and put a Detail Button on cell QTableWidget
    how to get The spesific row and column while i click The Button Detail in the cell QTableWidget

    what I can do right now is Retrive the Text using qDebug:

    @ for (int i=0; i<table->rowCount(); ++i)
    {

        qDebug()<< table->item(i, 0)->text();
        qDebug() << table->item(i, 1)->text();
        qDebug() << table->item(i, 2)->text();
    }
    

    @

    1 Reply Last reply
    0
    • M Offline
      M Offline
      mmallad
      wrote on last edited by
      #2

      First you can get Current Index
      @
      QModelIndex currentIndex = table->currentIndex();
      @
      than you can do
      @
      //For Column 0.
      qDebug() << table->item(currentIndex.row(), 0)->text();
      //For Column 1.
      qDebug() << table->item(currentIndex.row(), 1)->text();
      @
      I hope this will work. Because when you click the Detail Button than that row will be the current index.

      Dpak Malla

      1 Reply Last reply
      0
      • E Offline
        E Offline
        eyesBird
        wrote on last edited by
        #3

        anyway i have try to do that, but its still not working

        signal and slot:
        @connect(buttonDetail,SIGNAL(clicked(bool)),this,SLOT(getText()));
        @

        and my function slot:
        @void MainWindow::getText()// Detail Button
        {
        QModelIndex curentIndex = table->currentIndex();

        qDebug() << table->item(curentIndex.row(), 0)->text();
        qDebug() << table->item(curentIndex.row(), 1)->text();
        

        }

        @

        1 Reply Last reply
        0
        • M Offline
          M Offline
          mmallad
          wrote on last edited by
          #4

          Please make sure that getText() Slot is invoked while you click on the button. :) As i have told the currentIndex() gives the row and col of currently focused row so that when you are clicking on the button means u should have focus on that button :)

          Dpak Malla

          1 Reply Last reply
          0
          • E Offline
            E Offline
            eyesBird
            wrote on last edited by
            #5

            Thanks
            i wiil make sure of that

            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