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. [Solved] Automatically scroll to edited cell of QTableWidget?

[Solved] Automatically scroll to edited cell of QTableWidget?

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

    Hi,

    I am using a QTableWidget in Main Window class. There are more cells than the screen can show, hence scroll bars are created automatically. Now I am changing certain cells text by code. This happens successfully, but the scroll bars don't change automatically to show the edited cell. So if the cell is not in the visible region the user does not know which cell is getting changed. However when I manually scroll I find that the cell is selected automatically.

    So my question is what is the best way to update position of scroll bars, so that the cell that is selected may be visible to the user?
    Thanks!

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      What about "scrollTo":http://qt-project.org/doc/qt-4.8/qabstractitemview.html#scrollTo ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • CAD_codingC Offline
        CAD_codingC Offline
        CAD_coding
        wrote on last edited by
        #3

        Hi SGalst,
        Thanks for your answer.
        I am not a pro in C++ nor Qt.
        So I am finding it a bit difficult how to implement the said function.
        Can you please show by code how to use this for a QTableWidget?
        Thanks again :)

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          You don't have to implement it, just use it.

          Since you are modifying a known item, you can get it's index (you might already be using it) and call scrollTo with that index as a parameter

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • CAD_codingC Offline
            CAD_codingC Offline
            CAD_coding
            wrote on last edited by
            #5

            Oh yeah!
            I used scrollToItem() as that was much easier in my case.
            Thanks for your help :)

            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