Qt Forum

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

    Unsolved I'm trying to print QString variable to Textedit on ui How can i do? please help me in Below code

    General and Desktop
    2
    10
    53
    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.
    • M
      Mc6bullet last edited by VRonin

      #include "view_question.h"
      #include "ui_view_question.h"
      
      view_question::view_question(QWidget *parent) :
          QDialog(parent),
          ui(new Ui::view_question)
      {
          ui->setupUi(this);
          ui->Question_2->append(question);
      }
      
      view_question::~view_question()
      {
          delete ui;
      }
      
      void view_question::get_info(string que,string op1,string op2,string op3,string op4,string ans)
      {
          this->question= "Hello world";
          this->o1= QString::fromStdString(op1);
          this->o2= QString::fromStdString(op2);
          this->o3= QString::fromStdString(op3);
          this->o4= QString::fromStdString(op4);
          this->answer= QString::fromStdString(ans);
      }
      void view_question::on_pushButton_clicked()
      {
          qDebug(qUtf8Printable(o1));
          hide();
      }
      
      1 Reply Last reply Reply Quote 0
      • SGaist
        SGaist Lifetime Qt Champion last edited by

        Hi and welcome to devnet,

        What is your issue exactly ?
        When exactly do you want to append text to your QTextEdit ?

        On a side note, please using coding tags around your code. It's the </> button on the editor toolbar.

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

        M 1 Reply Last reply Reply Quote 0
        • M
          Mc6bullet @SGaist last edited by

          @SGaist Actually i have one variable name question i want display this variable on run time

          1 Reply Last reply Reply Quote 0
          • SGaist
            SGaist Lifetime Qt Champion last edited by

            When you call get_info ?

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

            M 1 Reply Last reply Reply Quote 0
            • M
              Mc6bullet @SGaist last edited by

              @SGaist It's getter setter i'm taking Qstring from it. but i want display that variable on ui how can do it? i'm new to qt therefore don't know how to do that? is there any other method to display variable on ui.

              1 Reply Last reply Reply Quote 0
              • SGaist
                SGaist Lifetime Qt Champion last edited by

                Use append like you do in the constructor if you want to see the new value when you change it.

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

                M 1 Reply Last reply Reply Quote 1
                • M
                  Mc6bullet @SGaist last edited by

                  @SGaist it is not working

                  1 Reply Last reply Reply Quote 0
                  • SGaist
                    SGaist Lifetime Qt Champion last edited by

                    What exactly are you doing ?
                    When are you doing it ?
                    Does the variable contain something ?

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

                    M 1 Reply Last reply Reply Quote 0
                    • M
                      Mc6bullet @SGaist last edited by

                      @SGaist i am making quiz maker so in that i want to display questions on the screen it is stored in Qstring format so i want to display that Qstring on window

                      1 Reply Last reply Reply Quote 0
                      • SGaist
                        SGaist Lifetime Qt Champion last edited by SGaist

                        Your goal is clear.

                        Now the questions are:

                        • How are you passing the question to that class ?
                        • When do you want the question to appear ?
                        • What exactly happens right now ?

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