PDA

View Full Version : insert number to qtextEdit



Jeneo W.
4th October 2010, 01:29
Hi

How Can insert number to qtextEdit ??

ChrisW67
4th October 2010, 04:59
No need to yell.

What's wrong with QTextEdit::setPlainText()?

marcvanriet
4th October 2010, 12:41
And to put a number in it, use e.g. :


ui->myEdit->setPlainText( QString::number( 123 ));

Regards,
Marc

Jeneo W.
5th October 2010, 00:35
Now I want using QlineEdit
as,

ui->lineEdit->textEdited( QString::number( 123 ) );

But i see this error,
error: 'void QLineEdit::textChanged(const QString&)' is protected

wysota
5th October 2010, 01:39
textEdited() is a signal.

ChrisW67
5th October 2010, 02:10
How about you try to describe what you are trying to achieve overall (in English not code) rather than firing off queries about each line of your code out of context. It strikes me that you might be better off with a QLineEdit or a QSpinBox if you are going to be soliciting numbers from the user.

Jeneo W.
5th October 2010, 02:18
I want a way to:
Get values from the user.
Put the values in the box.

Do you use the QLineEdit or qtextEdit :confused:

Jeneo W.
5th October 2010, 02:49
For, Get values from the user:

int x = ui->textEdit->toPlainText().toInt(&ok,10);
//Or
QString x = ui.textEdit->toPlainText();

and for, Put the values in the box:

ui->textEdit->setPlainText( QString::number( 123 ));

wysota
5th October 2010, 02:58
Use QSpinBox instead of QTextEdit. QTextEdit is for multi-line text, that's not what you want.