PDA

View Full Version : UI Loading Text



iasdev
12th February 2016, 15:05
Hello I am trying to load my .ini settings back into my UI.

I have the basic form down, from what I read in the QSettings doc and from what I could gather across the web, but I am still failing to understand how to load user saved text back into the UI.



void DLP3Dprinter::saveprogram()
{

QSettings settings("Moose Soft", "Clipper");

settings.beginGroup("MainWindow");
settings.setValue("size", size());
settings.setValue("pos", pos());
settings.setValue("Resolution",ui->StepResolutionText->toPlainText());
settings.endGroup();

}
void DLP3Dprinter::readsettings()
{
QSettings settings("Moose Soft", "Clipper");

settings.beginGroup("MainWindow");
resize(settings.value("size", QSize(400, 400)).toSize());
move(settings.value("pos", QPoint(200, 200)).toPoint());
//settings.setUserData("Resolution",ui->StepResolutionText->toPlainText());
//ui->StepResolutionText->setPlainText(QApplication::translate("DLP3Dprinter"," ?????",0));

// ui->StepResolutionText->setPlainText(settings.value("Resolution"));

settings.endGroup();


I am trying various methods to attain my desired result, but my programming knowledge is limited. Any help would be appreciated. I am sure this is pretty simple, once understood.

Thanks!

anda_skoa
12th February 2016, 15:36
When writing the settings you use ui->StepResolutionText->toPlainText() to the the value.

So ui->StepResolutionText is likely the element you want the loaded value to put into, correct?
In which case you locate the setter function that corresponds to the toPlainText() getter.
Assuming ui->StepResolutionText is of type QTextEdit, that would be setPlainText().



ui->StepResolutionText->setPlainText(settings.value("Resolution").toString());


Cheers,
_

iasdev
12th February 2016, 19:37
When writing the settings you use ui->StepResolutionText->toPlainText() to the the value.

So ui->StepResolutionText is likely the element you want the loaded value to put into, correct?
In which case you locate the setter function that corresponds to the toPlainText() getter.
Assuming ui->StepResolutionText is of type QTextEdit, that would be setPlainText().



ui->StepResolutionText->setPlainText(settings.value("Resolution").toString());


Cheers,
_

Perfect. Thank you good sir.

God Bless