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. I'm trying to print QString variable to Textedit on ui How can i do? please help me in Below code
QtWS25 Last Chance

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

Scheduled Pinned Locked Moved Unsolved General and Desktop
10 Posts 2 Posters 310 Views
  • 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 Offline
    M Offline
    Mc6bullet
    wrote on last edited by VRonin
    #1
    #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
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      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
      0
      • SGaistS SGaist

        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.

        M Offline
        M Offline
        Mc6bullet
        wrote on last edited by
        #3

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

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

          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
          0
          • SGaistS SGaist

            When you call get_info ?

            M Offline
            M Offline
            Mc6bullet
            wrote on last edited by
            #5

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

              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
              1
              • SGaistS SGaist

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

                M Offline
                M Offline
                Mc6bullet
                wrote on last edited by
                #7

                @SGaist it is not working

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

                  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
                  0
                  • SGaistS SGaist

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

                    M Offline
                    M Offline
                    Mc6bullet
                    wrote on last edited by
                    #9

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

                      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
                      1

                      • Login

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