ysncck
ysncck

Reputation: 113

How can I save Checkbox selection in qt c++?

I am trying to develop an application with QT C++. I added a checkBox. How can I make my checkBox be in the last selection when I close my app and open it again. For example, if the checkbox was selected before the application was closed, I want it to be selected when the application runs again. If it wasn't selected before closing, it should come back unselected when it runs again. How can I do that?

Upvotes: 1

Views: 165

Answers (1)

Jesper Juhl
Jesper Juhl

Reputation: 31474

Read the value of the checkbox when your app shuts down. Save the value somewhere, like; QSettings, a custom file, windows registry, etc. When your application starts, read the stored value and set the checkbox state to match.

Upvotes: 4

Related Questions