Reading text from a PlainTextEdit
Hello,
This I'm sure is an immensely stupid question, however it's so simple that I can't find the answer to it by searching anywhere. I want to take the information from a PlainTextEdit, put it into a variable and use it elsewhere (for example to populate another box later on). I have the following, where LatEdit and EastingText are both PlainTextEdit's, but get the error 'LatEdit was not declared in this scope'. If I change it to 'num1 = "TEST";' then it will work, so I'm assuming it's me reading in the text incorrectly from the LatEdit control.
Code:
void MainWindow::on_pushButton_clicked()
{
num1 = LatEdit->Plain;
ui->EastingText->setPlainText(num1);
}
Can anyone help me?
Thanks
Re: Reading text from a PlainTextEdit
are you forgetting to put 'ui->' in front of LatEdit?
Re: Reading text from a PlainTextEdit
QPlainTextEdit::toPlainText () ?
Code:
num1 = ui->LatEdit->toPlainText ();
Re: Reading text from a PlainTextEdit
Thank you, that worked! Didn't realise I needed toPlainText. More stupid questions to follow I expect...
Added after 31 minutes:
I'm not sure if I need to start a new thread, but I don't want to clog the board so I'll put it here. Could anyone tell me how I'd get mathematical functions into my code, such as Sine / Cosine etc.? Is there a math library I have to include?
Thanks again
Re: Reading text from a PlainTextEdit
you need to include <QtCore> then you have access to qCos,qSin etc
http://doc.qt.nokia.com/latest/qtcor...h.html#details
Re: Reading text from a PlainTextEdit
Hello,
I put
Code:
#include <qtcore/qmath.h>
at the top of the main.cpp and mainwindow.cpp units, however when using qSqrt it said 'qSqrt was not declared in this scope'. I can however use with the sqrt command and that's fine. Any ideas why the qmath unit doesn't work?