I'm trying to print QString variable to Textedit on ui How can i do? please help me in Below code
-
#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(); }
-
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.
-
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.
-
When you call get_info ?
-
Use append like you do in the constructor if you want to see the new value when you change it.
-
Use append like you do in the constructor if you want to see the new value when you change it.
-
What exactly are you doing ?
When are you doing it ?
Does the variable contain something ? -
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 ?