Unsolved Code for save as button
-
help write the code for the "save as" button, events are on_push_button_clicked , so that this button saves the text entered in lineEdit
-
@Qwerty123098 Please ask more concrete questions.
What did you try?
What does not work? -
@jsulm "save as" button for lineEdit, I wrote the code so that the button would open the file or save it in a file, but I wanted the button to save the file as
-
@Qwerty123098 I still don't understand what the problem is. Can you be more specific?
Just use https://doc.qt.io/qt-5/qfiledialog.html#getSaveFileName to ask user where to save and then write to that file. -
for example, in microsoft word or paint, when you have finished the project you click the save as button, and when you save, you give it the name and location of the file.
-
@Qwerty123098 I know what "Save as" is, that is not my question. My question is: what is the problem with implementing it?
Did you check the link I provided? -
@jsulm thanks, I figured it out
-
And one more question. How to save a .txt file that was written in lineEdit.
-
@Qwerty123098 Please read documentation:
https://doc.qt.io/qt-5/qtextstream.html
https://doc.qt.io/qt-5/qlineedit.html#text-prop -
I do not understand, you can write
-
@Qwerty123098 said in Code for save as button:
you can write
I can, but I will not - I'm not here to write code for you, sorry.
What exactly do you not understand? -
how to save text that was written in line Edit
-
@Qwerty123098 Get the text from the line edit using https://doc.qt.io/qt-5/qlineedit.html#text-prop, write it into the file using QFile and https://doc.qt.io/qt-5/qtextstream.html.
What is not clear?!
Did you even try to implement it?