- 1 Question (save as and save): What would be saved clearly and that when closing the window, if the file was not saved, then ask ("Are you sure you want to close the file?"). Also, if the file has not been saved anywhere else, then when clicking on "save", it opened a window in which we select the save location and that would remember the folder where we saved it. And most importantly - I want to save individual projects (this is in question number 3) and pictures, and that would save the visible window area.
- 2 Question (open as and open): To open files (projects that are in question 3) and also remember the last folder from which the project was opened.
- 3 Question (project): How to create your project, what would it have its own extension and what would be the icon and what would it open only in my program?
- You explain, what for and in what at you? If you get used to the IDE QtCreator, then separately. If you write something else here. Concrete need. - Alex.B
- I need such buttons to perform the functions that I described. And just write, if you know (I write my own) - notnames
1 answer
1) It is necessary to keep in memory the flag responsible for the state of the project. When closing the window, check the status of the flag and ask a question. Qt has a special property for a user interface notification that the file has been changed. To save to the file, store the path to the project file, when creating an empty project, leave the path empty. When saving, check if the path is empty, issue a request for the path, where to save.
2) The last folder to remember in the main window of the program and save to the config / registry when the window is closed ( QSettings ), at the start, respectively, read and give as the default path in QFileDialog .
3) Design your file format, you can binary, you can text as you prefer (binary smaller and faster, easier to debug text and edit with any text editor). When the program starts, analyze the launch keys ( QCoreApplication::arguments() ), the second one (with index 1) will contain the path to the project file that you should try to open.
You probably have a class that implements the project. If not, it needs to be done. It contains all the necessary data for calculations, it is possible to store the visualization settings in it. In the same place to store flags of a variability and ways which I described above. Implement saveToFile(QString) and loadFromFile(QString) methods to save / load a project from a file.
- Sorry, but I'm a beginner. Not everything is clear to me - notnames
- This is normal, we all started without knowing anything. However, your question contains several separate points and if you answer each one, you’ll get a rather large article. Try to specify exactly what is not clear. It was certainly better to split the question into several. - Bearded Beaver
- Okay. Let me list all the first answer, others do not need it yet. They are more or less clear to me, I will try to figure it out. But I ask, re-read the first question again. I just want to have the checks that I wrote about above - notnames
- Are you sure that “let me list the entire first answer” and “re-read the first question again” is this the right approach to people from whom you expect to get help? You have already been told that your question lacks specifics - which pictures, which area of ​​the visible window? Added an explanation of the implementation in response. It is impossible to suggest something more specific without seeing your code and your attempts to solve this problem. - Bearded Beaver
- I think you know about AdobePhotoshop . So, when they create a widget there (or a window, as you prefer), it appears separately and when you bring it into the program, it fits in with it and there is an area in it where you can do something. So I want to know how to do this. - notnames