Lets forget for a moment about ctSettings for simplicity.
A push button emits the signal clicked(). (If you need reaction on different button, you might need another signal)
This means that to react on the click you need to connect slot of QObject derived class instance to this signal.
Your MainWindow is such QObject derived class. So you can use it for such purpose.
I assume it also has access to the button pointer (for example ui->pushButton)
So now you need a slot. If writeSettings is a regular function just convert it to a slot.
Now we need to connect signal to slot.
In MainWindow constructor right after ui element are initialized (setuUi()?) add :
bool ok = connect(pushButton, SIGNAL(clicked()), this, SIGNAL(writeSettings ())); Q_ASSERT( ok);
Now writeSettings will be called when button is clicked and settings will be saved.
About ctSettings. There is no need to use custom class at least for this purpose,
but you can place all functionality in your custom class and use it if you prefer
void MainWindow::writeSettings()
{
ctSettings s;
s.writeSettings( ... );
}
Now you will need to pass parameters to ctSettings ::writeSettings( ... )
This better not be pointer to ui, cause you will introduce dependency ctSettings on the ui class which will be changed dynamically during development. Better to limit such dependency to MainWIndow.
( This is why you did not want to have ctSettings class )
In this case you would pass pass individual control like:
ctSettings s;
s.writeSettings( const QCheckBox* checkBox1 );
For all other questions I would recommend C++ book.
I can't explain what "private" is better than there.
Just understand that as soon in the code you see variable of specific type (class) mentioned,
it means compiler needs to know about this class already. Normally this means you have to include proper header file. (There is only one exception when incomplete class declaration is allowed, but book again will explain this much better than me).
Regards,
Alex