insert number to qtextEdit
Hi
How Can insert number to qtextEdit ??
Re: insert number to qtextEdit
No need to yell.
What's wrong with QTextEdit::setPlainText()?
Re: insert number to qtextEdit
And to put a number in it, use e.g. :
Code:
ui
->myEdit
->setPlainText
( QString::number( 123 ));
Regards,
Marc
Re: insert number to qtextEdit
Now I want using QlineEdit
as,
Code:
ui
->lineEdit
->textEdited
( QString::number( 123 ) );
But i see this error,
error: 'void QLineEdit::textChanged(const QString&)' is protected
Re: insert number to qtextEdit
textEdited() is a signal.
Re: insert number to qtextEdit
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.
Re: insert number to qtextEdit
I want a way to:
Get values from the user.
Put the values in the box.
Do you use the QLineEdit or qtextEdit :confused:
Re: insert number to qtextEdit
For, Get values from the user:
Code:
int x = ui->textEdit->toPlainText().toInt(&ok,10);
//Or
QString x
= ui.
textEdit->toPlainText
();
and for, Put the values in the box:
Code:
ui
->textEdit
->setPlainText
( QString::number( 123 ));
Re: insert number to qtextEdit
Use QSpinBox instead of QTextEdit. QTextEdit is for multi-line text, that's not what you want.