Why this problem has not been resolved:QPlainTextEdit Refresh slowly!!!!!!!!!!!!



  • first

    • The Control is QPlainTextEdit;
      Sceond:
    • The code below:
      @
      timer.start();
      pSerialPortQPlainTextEdit.insertPlainText("data");
      pSerialPortQPlainTextEdit.moveCursor(QTextCursor::End, QTextCursor::KeepAnchor);
      qDebug() << “The slow operation took” << timer.nsecsElapsed() <<“nanoseconds”;
      @
      The results are as follows:

    The slow operation took 1017500 nanoseconds
    The slow operation took 1018310 nanoseconds
    The slow operation took 1421502 nanoseconds
    The slow operation took 1186476 nanoseconds

    The slow operation took 10685984 nanoseconds
    The slow operation took 10668154 nanoseconds
    The slow operation took 10564419 nanoseconds
    The slow operation took 10569686 nanoseconds
    The slow operation took 10243486 nanoseconds
    The slow operation took 10473245 nanoseconds
    The slow operation took 10746766 nanoseconds
    The slow operation took 10772700 nanoseconds
    The slow operation took 10583059 nanoseconds
    The slow operation took 11221681 nanoseconds
    The slow operation took 10795798 nanoseconds
    The slow operation took 16827051 nanoseconds

    The slow operation took 222369451 nanoseconds
    The slow operation took 205003460 nanoseconds
    The slow operation took 222164411 nanoseconds
    The slow operation took 204823949 nanoseconds
    The slow operation took 209414655 nanoseconds
    The slow operation took 186572559 nanoseconds
    The slow operation took 209589304 nanoseconds
    The slow operation took 214433676 nanoseconds
    The slow operation took 219041401 nanoseconds

    Window refresh time becomes longer and longer!
    Can anybody help? Thanks!


  • Moderators

    You are constantly appending to the text, so I guess there is more data to process. Also, are you sure you are resetting the timer?

    It might be a bug, I do not know the internal implementation of this widget.



  • Hi sierdzio:
    My slot Code below:
    @
    void SerialPortWindow::slotsserialportupdateview(const QByteArray &DatatFormRead)
    {
    timer.start();
    pSerialPortQPlainTextEdit.insertPlainText("data");
    pSerialPortQPlainTextEdit.moveCursor(QTextCursor::End, QTextCursor::KeepAnchor);
    qDebug() << “The slow operation took” << timer.nsecsElapsed() <<“nanoseconds”;
    }
    @
    So it's no need to resetting the timer;
    Thanks for you reply!


  • Moderators

    The time clearly depends on the length of the text eg. you can see the same in the following case:
    @
    QString someGlobalText;

    ...
    void SerialPortWindow::slotsserialportupdateview(const QByteArray &DatatFormRead)
    {
    someGlobalText += "data";

    timer.start();
    pSerialPortQPlainTextEdit.setPlainText(someGlobalText);
    auto elapsed = timer.nsecsElapsed();

    qDebug() << “The slow operation took” << elapsed <<“nanoseconds”;
    }
    @
    This is hardly surprising. The more text the more needs to be drawn. Glyphs rendered, antialiasing, line breaks calculations, alignment etc. It takes time.

    Btw. you should call nsecsElapsed right after the operation you want to measure (see my example). If you call it like you did you are counting the time it took to print the "The slow operation took" to the debug stream which is out of your app control and may vary.



  • Hi sierdzio:
    #1.My code link:http://pan.baidu.com/s/1kTh0ifd.
    #2.There are many Chinese in code. heh
    #3.But please note The AccessPort operation Especially the time interval 1ms .
    #4.You can Open the AccessPort two time at the same time,One for tx ,one for rx .You will see ## the AccessPort refresh speed is so quickly.
    Thanks for you reply!


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.