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. qtextbrowser update from different class
Forum Updated to NodeBB v4.3 + New Features

qtextbrowser update from different class

Scheduled Pinned Locked Moved Solved General and Desktop
10 Posts 4 Posters 895 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.
  • T Offline
    T Offline
    Trojan Arun
    wrote on last edited by
    #1

    unable to update qt text browser from different class function.
    Try's:
    1.With qDebug function i can able to see my buffer content which i sent from other class, but updating to text browser wasn't happening.
    2.I used append function to update to my textbrowser

    JonBJ 1 Reply Last reply
    0
    • T Trojan Arun

      unable to update qt text browser from different class function.
      Try's:
      1.With qDebug function i can able to see my buffer content which i sent from other class, but updating to text browser wasn't happening.
      2.I used append function to update to my textbrowser

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by
      #2

      @Trojan-Arun
      Show some code, including what you are trying to append to what.
      It might be that using QTextEdit::append() is not going to work with the HTML you already have in your QTextBrowser. For example, if that already ends in </HTML>, and you just append without chopping off, I don't know whether it will ignore the extra stuff you add.

      1 Reply Last reply
      0
      • T Offline
        T Offline
        Trojan Arun
        wrote on last edited by
        #3

        This is MainWindow Class function:
        void MainWindow::print_in_text(QString temp)
        {
        qDebug()<<temp;
        QString print_buffer = temp;
        qDebug()<<print_buffer;
        ui->textBrowser->append(print_buffer);
        }

        This is EmitterTest Class

        void emittertest::text_function()
        {
        MainWindow *text;
        qDebug()<<"in text_function";
        QString buf="hello";
        text->print_in_text(buf);
        }

        Calling MainWindow class Function from EmitterTest Class function.

        1 Reply Last reply
        0
        • VRoninV Offline
          VRoninV Offline
          VRonin
          wrote on last edited by
          #4

          text is a dangling pointer in your example...

          "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
          ~Napoleon Bonaparte

          On a crusade to banish setIndexWidget() from the holy land of Qt

          1 Reply Last reply
          3
          • T Offline
            T Offline
            Trojan Arun
            wrote on last edited by
            #5

            void emittertest::text_function()
            {
            MainWindow text;
            qDebug()<<"in text_function";
            QString buf="hello";
            text.print_in_text("buf");
            }

            i even tried in this way... But textbrowser not appending buf content

            jsulmJ 1 Reply Last reply
            0
            • T Trojan Arun

              void emittertest::text_function()
              {
              MainWindow text;
              qDebug()<<"in text_function";
              QString buf="hello";
              text.print_in_text("buf");
              }

              i even tried in this way... But textbrowser not appending buf content

              jsulmJ Offline
              jsulmJ Offline
              jsulm
              Lifetime Qt Champion
              wrote on last edited by jsulm
              #6

              @Trojan-Arun said in qtextbrowser update from different class:

              But textbrowser not appending buf content

              How do you know? I mean, you do not show the main window.
              And now your text only exists inside text_function() - each time you call this method you create new main window...

              https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              2
              • T Offline
                T Offline
                Trojan Arun
                wrote on last edited by
                #7

                Sorry in my previous call i did that..
                here it is..

                Trojan Arun about 17 hours ago

                This is MainWindow Class function:
                void MainWindow::print_in_text(QString temp)
                {
                qDebug()<<temp;
                QString print_buffer = temp;
                qDebug()<<print_buffer;
                ui->textBrowser->append(print_buffer);
                }

                EmitterTest class
                void emittertest::text_function()
                {
                MainWindow text;
                qDebug()<<"in text_function";
                QString buf="hello";
                text.print_in_text("buf");
                }

                jsulmJ 1 Reply Last reply
                0
                • T Trojan Arun

                  Sorry in my previous call i did that..
                  here it is..

                  Trojan Arun about 17 hours ago

                  This is MainWindow Class function:
                  void MainWindow::print_in_text(QString temp)
                  {
                  qDebug()<<temp;
                  QString print_buffer = temp;
                  qDebug()<<print_buffer;
                  ui->textBrowser->append(print_buffer);
                  }

                  EmitterTest class
                  void emittertest::text_function()
                  {
                  MainWindow text;
                  qDebug()<<"in text_function";
                  QString buf="hello";
                  text.print_in_text("buf");
                  }

                  jsulmJ Offline
                  jsulmJ Offline
                  jsulm
                  Lifetime Qt Champion
                  wrote on last edited by jsulm
                  #8

                  @Trojan-Arun I know. But this does not answer my question.
                  So, again: how do you know this "But textbrowser not appending buf content"?

                  void emittertest::text_function()
                  {
                      MainWindow text; // This is local variable, each time you call text_function() you
                                       // create new text and append to it and not to the previous one
                      qDebug()<<"in text_function";
                      QString buf="hello";
                      text.print_in_text("buf");
                  }
                  

                  https://forum.qt.io/topic/113070/qt-code-of-conduct

                  1 Reply Last reply
                  3
                  • T Offline
                    T Offline
                    Trojan Arun
                    wrote on last edited by
                    #9

                    So, again: how do you know this "But textbrowser not appending buf content"?

                    • with the help of debug prints i m able to see my buf content in print_in_text mainwindow function.
                    jsulmJ 1 Reply Last reply
                    0
                    • T Trojan Arun

                      So, again: how do you know this "But textbrowser not appending buf content"?

                      • with the help of debug prints i m able to see my buf content in print_in_text mainwindow function.
                      jsulmJ Offline
                      jsulmJ Offline
                      jsulm
                      Lifetime Qt Champion
                      wrote on last edited by jsulm
                      #10

                      @Trojan-Arun I already explained you that you are creating a LOCAL variable "text". Are you aware of that? Make "MainWindow text" member variable in your emittertest class...

                      https://forum.qt.io/topic/113070/qt-code-of-conduct

                      1 Reply Last reply
                      3

                      • Login

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