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 to put the scrollbar at the bottom when I try to achieve a terminal-like dialog using QTextedit and QScrollbar?
QtWS25 Last Chance

How to put the scrollbar at the bottom when I try to achieve a terminal-like dialog using QTextedit and QScrollbar?

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 Posters 1.3k 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.
  • H Offline
    H Offline
    HYSuperman
    wrote on last edited by
    #1

    Here is the situation:
    I'm using QProcess to communicate with an external process. This process originally outputs its data into the terminal and now I want to redirect its output to my QT dialog. I'm using this method:
    @connect(mac_phy_Process, SIGNAL(readyReadStandardOutput()), this, SLOT(updateOutPutEdit()));@
    As you can see, the external process is 'mac_phy_Process' and I'm using readyReadStandardOutput() signal to communicate with it, when I catch this signal, I will update my QTextedit, here is my updateOutPutEdit slot:
    @void Configure::updateOutPutEdit(){
    QByteArray newData = mac_phy_Process->readAllStandardOutput();
    QString text = QString::fromLocal8Bit(newData);
    outPut->outPutWindow->insertPlainText(text);
    (outPut->scrollBar)->setValue(outPut->scrollBar->maximum());
    }@

    The 'output' is my dialog. 'outPutWindow' is a QTextEdit.
    I don't think my method is good, it isn't good for sure. Because the data comes quickly and everytime the data comes, I will put the scrollbar to the bottom location, this will prevent the user to drag it up, the user cannot see the output previously written.

    I'm figuring out a better way which I don't know, is there anyone who can help me with this ? thanks.
    Another problem: is there a size limit of QTextEdit? It turns out that everytime the QTextEdit cannot get the same output as terminal does, the QTextEdit loses data!

    1 Reply Last reply
    0
    • J Offline
      J Offline
      jafarabadi.qt
      wrote on last edited by
      #2

      Hi HYSuperman
      i think that if you set -1 for QTextEdit max-length it's change to unlimited, test it for yout own project and post your experience as reply.

      1 Reply Last reply
      0
      • H Offline
        H Offline
        HYSuperman
        wrote on last edited by
        #3

        I cannot find this function? What's its name ?
        [quote author="a.jafarabadi" date="1410588476"]Hi HYSuperman
        i think that if you set -1 for QTextEdit max-length it's change to unlimited, test it for yout own project and post your experience as reply.
        [/quote]

        1 Reply Last reply
        0
        • J Offline
          J Offline
          jafarabadi.qt
          wrote on last edited by
          #4

          check this thread it's useful:
          http://qt-project.org/faq/answer/how_can_i_get_set_the_max_length_of_a_qtextedit
          try it and come back to solve first problem
          ;)

          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