Results 1 to 3 of 3

Thread: UI Loading Text

  1. #1
    Join Date
    Feb 2016
    Posts
    3
    Qt products
    Qt5
    Platforms
    Windows

    Angry UI Loading Text

    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.

    Qt Code:
    1. void DLP3Dprinter::saveprogram()
    2. {
    3.  
    4. QSettings settings("Moose Soft", "Clipper");
    5.  
    6. settings.beginGroup("MainWindow");
    7. settings.setValue("size", size());
    8. settings.setValue("pos", pos());
    9. settings.setValue("Resolution",ui->StepResolutionText->toPlainText());
    10. settings.endGroup();
    11.  
    12. }
    13. void DLP3Dprinter::readsettings()
    14. {
    15. QSettings settings("Moose Soft", "Clipper");
    16.  
    17. settings.beginGroup("MainWindow");
    18. resize(settings.value("size", QSize(400, 400)).toSize());
    19. move(settings.value("pos", QPoint(200, 200)).toPoint());
    20. //settings.setUserData("Resolution",ui->StepResolutionText->toPlainText());
    21. //ui->StepResolutionText->setPlainText(QApplication::translate("DLP3Dprinter"," ?????",0));
    22.  
    23. // ui->StepResolutionText->setPlainText(settings.value("Resolution"));
    24.  
    25. settings.endGroup();
    To copy to clipboard, switch view to plain text mode 

    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!

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,396
    Thanks
    37
    Thanked 1,542 Times in 1,493 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: UI Loading Text

    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().

    Qt Code:
    1. ui->StepResolutionText->setPlainText(settings.value("Resolution").toString());
    To copy to clipboard, switch view to plain text mode 

    Cheers,
    _

  3. #3
    Join Date
    Feb 2016
    Posts
    3
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: UI Loading Text

    Quote Originally Posted by anda_skoa View Post
    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().

    Qt Code:
    1. ui->StepResolutionText->setPlainText(settings.value("Resolution").toString());
    To copy to clipboard, switch view to plain text mode 

    Cheers,
    _
    Perfect. Thank you good sir.

    God Bless

Similar Threads

  1. Replies: 3
    Last Post: 2nd August 2012, 13:46
  2. Qt QTextEdit loading just half text file
    By enthalio1 in forum Qt Programming
    Replies: 3
    Last Post: 1st August 2012, 02:54
  3. Replies: 5
    Last Post: 16th June 2011, 12:16
  4. Loading files with text and images in TextEdit
    By dshan in forum Qt Programming
    Replies: 1
    Last Post: 11th January 2011, 09:52
  5. Replies: 1
    Last Post: 3rd September 2008, 14:16

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.