简体   繁体   中英

How to find length of data displayed in QTextEdit

I am displaying real time live data from a device in QTextEdit, the length of data is more than size of QTextEdit, so scrolls appear, but they are useless as they can't be moved since new data is replacing the old data continuously. so I can't see the full data. So I removed the scroll, now the data is truncated, now I want to know the length of truncated data so that I can make provision for displaying that data too..

Having a GUI element change size frequently may not be the desirable, so maybe you could take a different route:

  • Enable the scroll bars.
  • When the user touches the scroll bars, stop updating the widget and start a timer object (fires after X seconds).
  • When the user scrolls, reset the timer.
  • After X seconds of inactivity or when the user scrolls to the top, start updating the widget again.

Another option: Add a button to enable/disable updates to the widget so the user can peacefully read it's contents.

Would it be an option to buffer the data behind the scenes and to provide the user a "Refresh" button that allows him to get (part of the) the data from the buffer into the QTextEdit?

Each time he presses the "Refresh" button he'd get another chunk from the buffer, while at the same time you add to it so you don't lose anything.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM