Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to save CheckBox state
Forum Updated to NodeBB v4.3 + New Features

How to save CheckBox state

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 398 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • naaxN Offline
    naaxN Offline
    naax
    wrote on last edited by
    #1

    Hello.
    I want to save and load the checkbox state but I cant do it.

    //I saving it as :
    stream << ui->Task1->isChecked() <<"\n";
    
    //and  i tried this to load
     ui->Task1->setChecked(ui->Task1->isChecked()) = line11;
    
    

    but of course, it's not working because the expression is not assignable. I don't know how I can load it to my program. Can you help me maybe?

    jsulmJ 1 Reply Last reply
    0
    • naaxN Offline
      naaxN Offline
      naax
      wrote on last edited by
      #3

      @jsulm

      Tnx.

      QString line11 = in.readLine();
                   ui->Task1->setChecked(line11.toInt());
      

      Works

      1 Reply Last reply
      0
      • naaxN naax

        Hello.
        I want to save and load the checkbox state but I cant do it.

        //I saving it as :
        stream << ui->Task1->isChecked() <<"\n";
        
        //and  i tried this to load
         ui->Task1->setChecked(ui->Task1->isChecked()) = line11;
        
        

        but of course, it's not working because the expression is not assignable. I don't know how I can load it to my program. Can you help me maybe?

        jsulmJ Offline
        jsulmJ Offline
        jsulm
        Lifetime Qt Champion
        wrote on last edited by jsulm
        #2

        @naax said in How to save CheckBox state:

        line11

        What is this? You need to read from the stream, convert to a boolean and then set it using ui->Task1->setChecked(...)
        Also you should check https://doc.qt.io/qt-5/qsettings.html

        https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply
        0
        • naaxN Offline
          naaxN Offline
          naax
          wrote on last edited by
          #3

          @jsulm

          Tnx.

          QString line11 = in.readLine();
                       ui->Task1->setChecked(line11.toInt());
          

          Works

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved