Automatically saving the operation through passing the command line argument

I already have a save function in my tool as like a normal tools. Now I would like to add auto save function, that has to save all the operation that made in the tool(we called that overlays) without pressing ctrl+S, have to done automatically. I need to write an auotsave function and I have to pass as command line arguments. Could some one will help me out. More detail: When I right to open my tool in Linux, mostly we used to pass like cd home/...bla bla../ and ToolName. I need to use the autosave function as command line arguments. for eg: When I pass the argument as -s for automatically saving function when I try to pass like........ ToolName -s......... it has to save the data or operation automatically which is performed in my tool. looking for your valuable answers

1
2
3
4
5
6
7
  mFileMenu->addSeparator();
    
    mSaveAction = mFileMenu->addAction(tr("&Save"), this, SLOT(slotOpenFileDialog()));
    mSaveAction->setShortcut( tr( "Ctrl+S" ) );
    mSaveAction->setToolTip("Save...");
    mSaveAction->setIcon(QIcon( ":/newIcons/RodIcons/ROD_Icons_Save.png" ));
    mToolBarOpen->addAction(mSaveAction);
Command line argument. See the example in:
http://doc.qt.io/Qt-5/qapplication.html#details

Do you notice how the argv is searched for "-no-gui"?
You want to do something, if the argv contains "-s".

The "something" is up to you.


When should the program do "something"? At start? At quit?
You can store a flag at start.
You can check the flag and act when closing.


You show code that is manually written? Qt has visual Designer and uic that can generate such code.
Thank for your reply. I am using Qt.. I already set the command line argument but I dont know how to set the argument to my save function . What is the easiest way to perform autosave function using the command line arguments. More detail: I have a save function like noraml tool (Ctrl +S). I have a command line argument that is defined as (-A). I have to use this -A to perform the save function automatically. If I pass the command in Linux for eg: " ToolName -A ". It has to save the operation that has been made in thetool. what would be the easiest way to perform auto save.
You "have set the argument but don't know how to set argument"?

I clearly don't know the question, so I create a conceptual answer:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
int main( int argc, char* argv[] )
{
  const std::string OPT = "-A";
  bool hasOption =  false;
  for ( int i = 1; i < argc; ++i ) {
    if ( OPT == argv[i] ) {
      hasOption = true;
      break;
    }
  }

  if ( hasOption ) {
    // do something
  }
  return 0;
}
This is what I did so far from my main funct
int main(int argc, char *argv[])
{
/* if(argc >= 2 && strncmp(argv[1], "-A", 2) */
if (argv[1])
{
if(strcmp(argv[1], "-A")==0)
{
printf("Save the overlays \n", Need a funct);
return 0;
}

}
I set argument -A,
But I need to know how can I root the argument to save function. In Linux console, If I give ToolName -A it has to save the operation automatically. My question is what is the procedure to form an save function to be automatic. You can go through the saving functionality in my first post
You could use timer. When the timer fires you call the save function
Topic archived. No new replies allowed.