Unsolved 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.
-
@SGaist Actually i have one variable name question i want display this variable on run time
-
When you call get_info ?
-
@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.
-
Use append like you do in the constructor if you want to see the new value when you change it.
-
@SGaist it is not working
-
What exactly are you doing ?
When are you doing it ?
Does the variable contain something ? -
@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
-
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 ?