Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. International
  3. India
  4. Regarding position of hlighlighter in QTableWidget
QtWS25 Last Chance

Regarding position of hlighlighter in QTableWidget

Scheduled Pinned Locked Moved India
4 Posts 2 Posters 1.6k 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.
  • S Offline
    S Offline
    srchaitanya2008
    wrote on last edited by
    #1

    Hello everyone,

    I am a newbie to Qt. I tried Googling for the problem, but I was not able to find it and hence posting here. If I have a 4x4 table and if I want to get the postion of highlighter in the table, what function should I use?? My expectation is that when the highlighter reaches the edge of the table (last row or last column), and when a button is pressed(say when the highlighter is at the last row and down button is pressed), I want to update the contents of the table. How to do this?? Please guide me in this regard.

    Thanks,
    Chaitanya

    1 Reply Last reply
    0
    • p3c0P Offline
      p3c0P Offline
      p3c0
      Moderators
      wrote on last edited by
      #2

      Hi,

      You can use "currentRow":http://qt-project.org/doc/qt-5.0/qtwidgets/qtablewidget.html#currentRow and "currentColumn":http://qt-project.org/doc/qt-5.0/qtwidgets/qtablewidget.html#currentColumn to get the row and column index of current item.
      So when you press the button get the currentRow and currentColumn and check if it matches with your requirement and then populate your tablewidget.

      157

      1 Reply Last reply
      0
      • S Offline
        S Offline
        srchaitanya2008
        wrote on last edited by
        #3

        Hello,

        Thanks for your reply. So there is no inbuilt function which can detect when the end of table is reached??

        Thanks in advance,
        Chaitanya

        1 Reply Last reply
        0
        • p3c0P Offline
          p3c0P Offline
          p3c0
          Moderators
          wrote on last edited by
          #4

          Hi,

          AFAIK, there's no direct function which can detect it.
          There's a simple way, use the "currentCellChanged":http://qt-project.org/doc/qt-5.0/qtwidgets/qtablewidget.html#currentCellChanged signal and check if the focus is currently at the last item.
          For e.g
          @
          void MainWindow::on_tableWidget_currentCellChanged(int currentRow, int currentColumn, int previousRow, int previousColumn)
          {
          qDebug() << currentRow << currentColumn;
          if(currentRow==ui->tableWidget->rowCount()-1 && currentColumn==ui->tableWidget->columnCount()-1)
          qDebug() << "End of table reached";
          }
          @

          For this you need to connect currentCellChanged signal to the slot on_tableWidget_currentCellChanged(int currentRow, int currentColumn, int previousRow, int previousColumn)

          157

          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