Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to save a text file directly without using QfileDialog box?

How to save a text file directly without using QfileDialog box?

Scheduled Pinned Locked Moved Unsolved General and Desktop
qt 5.4c++qfiledialogqtextedit
4 Posts 2 Posters 684 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Mr-Workalot
    wrote on 28 Jul 2020, 02:33 last edited by
    #1

    f7e6c843-645e-4aed-8628-3e2eb92696b9-image.png

    This is my sample UI, the white box is a textbox which will have some items, my main question is that when i click "Save/Refresh" qpushbutton, i want to save all of the qtextbox text into a textfile/sample_name.xml into a designated folder, but i dont wanna go through Qfiledialog box and having to decide/browse a location in which the file needs to be saved, i just want it to be saved at a fixed place in C-drive ,

    and also the text in the qtextbox should again be loaded with that sample_name.xml file, i know the content is gonna be the same as i just saved it , but still i need it for some other functionality.

    How can i acheive this without the involvement of qfiledialog ?

    J 1 Reply Last reply 28 Jul 2020, 05:27
    0
    • M Mr-Workalot
      28 Jul 2020, 02:33

      f7e6c843-645e-4aed-8628-3e2eb92696b9-image.png

      This is my sample UI, the white box is a textbox which will have some items, my main question is that when i click "Save/Refresh" qpushbutton, i want to save all of the qtextbox text into a textfile/sample_name.xml into a designated folder, but i dont wanna go through Qfiledialog box and having to decide/browse a location in which the file needs to be saved, i just want it to be saved at a fixed place in C-drive ,

      and also the text in the qtextbox should again be loaded with that sample_name.xml file, i know the content is gonna be the same as i just saved it , but still i need it for some other functionality.

      How can i acheive this without the involvement of qfiledialog ?

      J Offline
      J Offline
      jsulm
      Lifetime Qt Champion
      wrote on 28 Jul 2020, 05:27 last edited by
      #2

      @Mr-Workalot said in How to save a text file directly without using QfileDialog box?:

      How can i acheive this without the involvement of qfiledialog ?

      Using QFile...
      If you're asking how to find some specific location (not clear from your post) then see https://doc.qt.io/qt-5/qstandardpaths.html

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      M 1 Reply Last reply 28 Jul 2020, 07:21
      4
      • J jsulm
        28 Jul 2020, 05:27

        @Mr-Workalot said in How to save a text file directly without using QfileDialog box?:

        How can i acheive this without the involvement of qfiledialog ?

        Using QFile...
        If you're asking how to find some specific location (not clear from your post) then see https://doc.qt.io/qt-5/qstandardpaths.html

        M Offline
        M Offline
        Mr-Workalot
        wrote on 28 Jul 2020, 07:21 last edited by
        #3

        @jsulm Yes, exactly how to set that specific location??

        J 1 Reply Last reply 28 Jul 2020, 07:24
        0
        • M Mr-Workalot
          28 Jul 2020, 07:21

          @jsulm Yes, exactly how to set that specific location??

          J Offline
          J Offline
          jsulm
          Lifetime Qt Champion
          wrote on 28 Jul 2020, 07:24 last edited by
          #4

          @Mr-Workalot But what location do you need? Where do you want to store the file? It is really not clear from your description.
          Did you check the link I provided: https://doc.qt.io/qt-5/qstandardpaths.html ?
          Example: to store in Documents folder call https://doc.qt.io/qt-5/qstandardpaths.html#writableLocation with QStandardPaths::DocumentsLocation as parameter

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          4

          1/4

          28 Jul 2020, 02:33

          • Login

          • Login or register to search.
          1 out of 4
          • First post
            1/4
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved