Noob Qt question re: QStrings and lineEdit...
-
This is my first foray into QTness...
I'm simply trying to get USER input from-----------------------teexxt = ui->lineEdit->text();
and to display it to------------------------------------------------------ui->textBrowser->setText(teexxt);
Everything is working fine... but what I'm trying to achieve is that for every press of ----<void KimWidget::on_EnterButton_clicked()>
the button... the text should add to the current text and not replace it.
Currently everytime I press the button... the text in the textBrowser area is completely replaced by the new text.
Here's the cpp file:
#include "kimwidget.h"
#include "ui_kimwidget.h"
#include "QLineEdit.h"
#include <QTextStream>KimWidget::KimWidget(QWidget *parent) : QWidget(parent), ui(new Ui::KimWidget)
{
ui->setupUi(this);}
KimWidget::~KimWidget()
{
delete ui;
}void KimWidget::on_EnterButton_clicked()
{
QString text2 = ui->lineEdit->text();
QString text3;text3.append(text2); ui->textBrowser->setText(text3); ui->lineEdit->clear();
}
-
move QString text3; outside on_EnterButton_clicked()
-
Success!!!!! I just moved <QString text3;> outside as suggested. :)
I forgot to mention... I tried declaring in the main.cpp file earlier... it didn't work.
All 3 files are confusing. Not quite sure where to do what. :)Thanks again! Now I'll try the <ui->textBrowser->append(text2);> route... without declaring <QString text3;> outside...