Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct

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

    General and Desktop
    2
    4
    1097
    Loading More Posts
    • 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
      HYSuperman last edited by

      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 Reply Quote 0
      • J
        jafarabadi.qt last edited by

        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 Reply Quote 0
        • H
          HYSuperman last edited by

          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 Reply Quote 0
          • J
            jafarabadi.qt last edited by

            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 Reply Quote 0
            • First post
              Last post