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. QPlainText: not update after append text
Forum Updated to NodeBB v4.3 + New Features

QPlainText: not update after append text

Scheduled Pinned Locked Moved Solved General and Desktop
11 Posts 3 Posters 1.5k 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.
  • F Offline
    F Offline
    fem_dev
    wrote on last edited by fem_dev
    #1

    I create a console window using QPlainTextEdit used to display my application status.

    It was created inside the app.ui.
    So, if I use appendPlainText() or appendHtml() from any method inside my App Class, it works good!

    But now, I have another class (*.ui) that need to send a message to the App Class and shows it on my QPlainTextEdit console.

    So I send a signal from my anotherClass with some text, like:

    class AnotherClass 
    {
    ...
    signals:
         sendMsg(QString msg);
    }
    
    class AppClass
    {
    ....
    slots:
        receiveMsg(QString msg);
    }
    
    AppClass::receiveMsg(QString msg)
    {
        // Append text Ok, but not refresh QPlainTextEdit.
        // It only shows the appended text when I manually scroll the QPlainTextEdit
        // Not auto "refresh" and not "auto scroll" to the bottom
        ui->qplaintextedit->appendPlainText(msg);
    
        // I ALREADY TRIED:
        // A)
        // int v = ui->qplaintextedit->verticalScrollBar()->maximum();
        // ui->qplaintextedit->verticalScrollBar()->setValue(v);
    
        // B)
        // ui->qplaintextedit->setCenterOnScroll(true);
        // ui->qplaintextedit->centerCursor();
    
        // C)
        // ui->qplaintextedit->show();
    }
    

    In this case (signal and slot) how can I auto refresh and scroll the QPlainTextEdit to the bottom?

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

      The bug report system

      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
      1
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #2

        Hi,

        What does that other class do ?
        Does it do any heaving computation ?

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

        F 1 Reply Last reply
        0
        • SGaistS SGaist

          Hi,

          What does that other class do ?
          Does it do any heaving computation ?

          F Offline
          F Offline
          fem_dev
          wrote on last edited by
          #3

          @SGaist at this time...no.
          The AnotherClass is simple...I just want to send a msg from AnotherClass to AppClass and see it on the QPlainText console with auto refresh and scroll to the bottom line.

          In the future, may be, I will implemente other classes that will have some heavy computation power.

          Could you help me?

          1 Reply Last reply
          0
          • F Offline
            F Offline
            fem_dev
            wrote on last edited by
            #4

            Any ideas?

            1 Reply Last reply
            0
            • Christian EhrlicherC Offline
              Christian EhrlicherC Offline
              Christian Ehrlicher
              Lifetime Qt Champion
              wrote on last edited by
              #5

              @fem_dev said in QPlainText: not update after append text:

              Any ideas?

              What OS do you have? Did you also search the Qt bug tracker?
              Please provide a minimal example so we can test it locally.

              Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
              Visit the Qt Academy at https://academy.qt.io/catalog

              F 1 Reply Last reply
              1
              • Christian EhrlicherC Christian Ehrlicher

                @fem_dev said in QPlainText: not update after append text:

                Any ideas?

                What OS do you have? Did you also search the Qt bug tracker?
                Please provide a minimal example so we can test it locally.

                F Offline
                F Offline
                fem_dev
                wrote on last edited by fem_dev
                #6

                @Christian-Ehrlicher
                I copied my Qt project from a Mac OSX Catalina machine to another computer that is running Ubuntu 20.04.

                When I run it on Ubuntu, it works perfect! No issues.

                It automatically "refresh" and scroll to the bottom line.


                A simple example:

                AnotherClass::AnotherClass()
                {
                    emit sendMsg("This is a msg from anotherClass");
                }
                
                AppClass::receiveMsg(QString msg)
                {
                    ui->qplaintextedit->appendPlainText(msg);
                }
                

                May be this problem is just in OSX Catalina....I don't know...

                Important: Both OSX Catalina and Ubuntu 20.04 machines are running:

                • Qt Creator 4.12.3
                • Qt 5.15

                Please, tell me if you need more details...

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

                  Emitting a signal in a constructor is a bad idea as you can't have connected it to a slot at that point in time.

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

                  F 1 Reply Last reply
                  3
                  • SGaistS SGaist

                    Emitting a signal in a constructor is a bad idea as you can't have connected it to a slot at that point in time.

                    F Offline
                    F Offline
                    fem_dev
                    wrote on last edited by
                    #8

                    @SGaist sorry....

                    I just put the emit in the constructor only in this simple example, but int my real code this emit is outside the class constructor...

                    I did it here just to explain my question.

                    The key point is that:
                    The receiveMsg() was triggered and I got the QString msg with success.
                    I think that the msg is already appended to my qplaintextedit, but this widget IS NOT SHOWING automatically the appended msg. May be the QPlainTextEdit UI is not rendering as it should be.

                    So, after that, if I MANUALLY scroll the QPlainTextEdit vertically up and down, this widget "refresh" and shows the appended msg at the bottom line.

                    Any ideas?

                    May be this problem is just in OSX Catalina....I don't know...

                    Important: Both OSX Catalina and Ubuntu 20.04 machines are running:

                    • Qt Creator 4.12.3
                    • Qt 5.15
                    1 Reply Last reply
                    0
                    • Christian EhrlicherC Offline
                      Christian EhrlicherC Offline
                      Christian Ehrlicher
                      Lifetime Qt Champion
                      wrote on last edited by
                      #9

                      Since it seems to be easy to reproduce I would create a testcase and open a bug report.

                      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                      Visit the Qt Academy at https://academy.qt.io/catalog

                      F 1 Reply Last reply
                      2
                      • Christian EhrlicherC Christian Ehrlicher

                        Since it seems to be easy to reproduce I would create a testcase and open a bug report.

                        F Offline
                        F Offline
                        fem_dev
                        wrote on last edited by
                        #10

                        @Christian-Ehrlicher It's my first time reporting a possible bug...

                        Where should I report it? Do you have a link?

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

                          The bug report system

                          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
                          1

                          • Login

                          • Login or register to search.
                          • First post
                            Last post
                          0
                          • Categories
                          • Recent
                          • Tags
                          • Popular
                          • Users
                          • Groups
                          • Search
                          • Get Qt Extensions
                          • Unsolved