I am currently creating a dialog with a check box that says “Do no display again”. When the check box is clicked and the dialog is closed (ok button pressed), the application will store in QSettings that this dialog box has been opened before.
I’m not familiar with Qt settings and looking at the API, I don’t know which function to use.
Could anyone point me to the right direction? Thank you!
Btw I did try QErrorMessage, but the message box keeps popping up so I gave up on it.
void MessageBox::on_checkBox_stateChanged(int arg1)
{
if(ui->checkBox->stateChanged(arg1) && ui->pushButton->clicked(true))
//I believe this is right.
{
writeSettings();
}
}
void MessageBox::writeSettings()
{
QSettings settings;
//...help; Question: Should I write in main.cpp or in the .h?
}
void MessageBox::readSettings()
{
//...help
}
To use the QSettings constructor in this form, you must set the organization and application name for your application, probably in main.cpp if you create it there:
Then in your writeSettings() you do:
and in readSettings()
It’s all in the docs and explained quite clearly IMO.