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. A problem i have with palettes i need help with!
Forum Updated to NodeBB v4.3 + New Features

A problem i have with palettes i need help with!

Scheduled Pinned Locked Moved Unsolved General and Desktop
27 Posts 5 Posters 2.6k Views 3 Watching
  • 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.
  • K Kris Revi

    @mrjj ty for that bit of code m8! :) <3

    question! is this the way togo when you want to save the file to the App folder?

    if ( pix.save(QDir::currentPath() + "/test.png") )
    
    jsulmJ Offline
    jsulmJ Offline
    jsulm
    Lifetime Qt Champion
    wrote on last edited by
    #15

    @Kris-Revi You should not write into app folder as usually normal users have no write access there!
    There are better options for saving data, see https://doc.qt.io/qt-5/qstandardpaths.html

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

    K 1 Reply Last reply
    2
    • jsulmJ jsulm

      @Kris-Revi You should not write into app folder as usually normal users have no write access there!
      There are better options for saving data, see https://doc.qt.io/qt-5/qstandardpaths.html

      K Offline
      K Offline
      Kris Revi
      wrote on last edited by
      #16

      @jsulm realy! well what would be a normal place to put this then? :)

      jsulmJ 1 Reply Last reply
      0
      • K Kris Revi

        @jsulm realy! well what would be a normal place to put this then? :)

        jsulmJ Offline
        jsulmJ Offline
        jsulm
        Lifetime Qt Champion
        wrote on last edited by
        #17

        @Kris-Revi Did you actually read the link I gave you?
        There are several locations depending on type of files:

        • QStandardPaths::DocumentsLocation - any documents
        • QStandardPaths::PicturesLocation - for pictures (this is probably what you want)
        • ...

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

        K 1 Reply Last reply
        2
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #18

          You can either use QFileDialog so your users can choose where to store them or use one of the suitable proposition of QStandardPaths like QStandardPaths::DocumentsLocation

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          1
          • jsulmJ jsulm

            @Kris-Revi Did you actually read the link I gave you?
            There are several locations depending on type of files:

            • QStandardPaths::DocumentsLocation - any documents
            • QStandardPaths::PicturesLocation - for pictures (this is probably what you want)
            • ...
            K Offline
            K Offline
            Kris Revi
            wrote on last edited by
            #19

            @jsulm ofcourse i read it! i was asking where do people usualy put it :) im not THAT lazy! :)

            jsulmJ 1 Reply Last reply
            0
            • K Kris Revi

              @jsulm ofcourse i read it! i was asking where do people usualy put it :) im not THAT lazy! :)

              jsulmJ Offline
              jsulmJ Offline
              jsulm
              Lifetime Qt Champion
              wrote on last edited by
              #20

              @Kris-Revi Sorry if I was rude!
              Where to put the data depends on data types. It looks like you want to store a picture, so QStandardPaths::PicturesLocation would be the proper location. Or you ask the user where to store as @SGaist suggested.

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

              K 1 Reply Last reply
              1
              • jsulmJ jsulm

                @Kris-Revi Sorry if I was rude!
                Where to put the data depends on data types. It looks like you want to store a picture, so QStandardPaths::PicturesLocation would be the proper location. Or you ask the user where to store as @SGaist suggested.

                K Offline
                K Offline
                Kris Revi
                wrote on last edited by
                #21

                @jsulm np! was not rude :)

                im asking because when installing almost any software it always creates a folder in the "C:/user/username/appdata" folder was wondering if that was a default/standard !

                suggesting documents seemed weird to me as these "pictures" are generated and used by the APP and not the user and as i write this i think (appdata) would be the place

                jsulmJ 1 Reply Last reply
                0
                • K Kris Revi

                  @jsulm np! was not rude :)

                  im asking because when installing almost any software it always creates a folder in the "C:/user/username/appdata" folder was wondering if that was a default/standard !

                  suggesting documents seemed weird to me as these "pictures" are generated and used by the APP and not the user and as i write this i think (appdata) would be the place

                  jsulmJ Offline
                  jsulmJ Offline
                  jsulm
                  Lifetime Qt Champion
                  wrote on last edited by
                  #22

                  @Kris-Revi said in A problem i have with palettes i need help with!:

                  C:/user/username/appdata

                  Yes, this folder can be used by your app to write its data in its subfolder. But "pix.save(QDir::currentPath()" will not return this path. Use QStandardPaths::AppLocalDataLocation to get that path.

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

                  K 2 Replies Last reply
                  0
                  • jsulmJ jsulm

                    @Kris-Revi said in A problem i have with palettes i need help with!:

                    C:/user/username/appdata

                    Yes, this folder can be used by your app to write its data in its subfolder. But "pix.save(QDir::currentPath()" will not return this path. Use QStandardPaths::AppLocalDataLocation to get that path.

                    K Offline
                    K Offline
                    Kris Revi
                    wrote on last edited by
                    #23

                    @jsulm said in A problem i have with palettes i need help with!:

                    Yes, this folder can be used by your app to write its data in its subfolder. But "pix.save(QDir::currentPath()" will not return this path. Use QStandardPaths::AppLocalDataLocation to get that path.

                    yea i wrote som vars

                        QString save_path = QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation);
                        QString palette_folder = "/palettes";
                    
                    1 Reply Last reply
                    0
                    • jsulmJ jsulm

                      @Kris-Revi said in A problem i have with palettes i need help with!:

                      C:/user/username/appdata

                      Yes, this folder can be used by your app to write its data in its subfolder. But "pix.save(QDir::currentPath()" will not return this path. Use QStandardPaths::AppLocalDataLocation to get that path.

                      K Offline
                      K Offline
                      Kris Revi
                      wrote on last edited by
                      #24

                      @jsulm hmm but for android there is no such path as C:/user/username/appdata .... where would i store them there?

                      jsulmJ 1 Reply Last reply
                      0
                      • K Kris Revi

                        @jsulm hmm but for android there is no such path as C:/user/username/appdata .... where would i store them there?

                        jsulmJ Offline
                        jsulmJ Offline
                        jsulm
                        Lifetime Qt Champion
                        wrote on last edited by
                        #25

                        @Kris-Revi There should be app data folder (of course it is not C:/user/username/appdata on Android). Try QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation) on Android and see what it returns.

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

                        1 Reply Last reply
                        0
                        • SGaistS Offline
                          SGaistS Offline
                          SGaist
                          Lifetime Qt Champion
                          wrote on last edited by
                          #26

                          QStandardPaths will return you suitable paths for the platform you are targeting however you should always check that the folder exists and create it if not prior to do anything else. While the path you will get is valid, it does not mean it exists yet as it does not make sense for the system to create them all since not every app will use these folders. Especially on mobile OS where the application storage and the user data it may create are located on different spaces on the device.

                          Interested in AI ? www.idiap.ch
                          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                          K 1 Reply Last reply
                          2
                          • SGaistS SGaist

                            QStandardPaths will return you suitable paths for the platform you are targeting however you should always check that the folder exists and create it if not prior to do anything else. While the path you will get is valid, it does not mean it exists yet as it does not make sense for the system to create them all since not every app will use these folders. Especially on mobile OS where the application storage and the user data it may create are located on different spaces on the device.

                            K Offline
                            K Offline
                            Kris Revi
                            wrote on last edited by
                            #27

                            @SGaist ofcourse :) i've made a init file that on startup checks every folder, path and file, if they exists (fi not create them) and if can we access them :) for this i made this

                                Debug_pff.LevelInfo("PFF", "Checking if folder exists", "!");
                                if ( !QDir(save_path + palette_folder).exists() )
                                {
                                    QDir().mkdir(save_path + palette_folder);
                                    Debug_pff.LevelInfo("PFF", "Folder did not exist so we created one", "!");
                                }
                            
                            1 Reply Last reply
                            0

                            • Login

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