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. SAVE AND LOAD image in Directory

SAVE AND LOAD image in Directory

Scheduled Pinned Locked Moved Solved General and Desktop
10 Posts 2 Posters 5.3k 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
    M4RZB4Ni
    wrote on 25 Aug 2016, 16:06 last edited by
    #1

    Hello
    before i wanted to save users pictures in my database
    and i searched on web and seen that this work doing database heavy for loading
    and this better to save images on Directory and save Image path to Table
    and load it From Directory!

    i write this code for save image but do nothing!

    QImage originalPixmap;
    originalPixmap.save("D:\\Projects\\physiotherapy\\sickpic"+filename);
    
    

    any body can help me please?

    1 Reply Last reply
    0
    • V Offline
      V Offline
      VRonin
      wrote on 25 Aug 2016, 16:56 last edited by
      #2

      the folder tree should exist (QImage will not create folders) and filename should contain the extension otherwise you have to provide it as second argument

      "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
      ~Napoleon Bonaparte

      On a crusade to banish setIndexWidget() from the holy land of Qt

      M 1 Reply Last reply 25 Aug 2016, 16:57
      0
      • V VRonin
        25 Aug 2016, 16:56

        the folder tree should exist (QImage will not create folders) and filename should contain the extension otherwise you have to provide it as second argument

        M Offline
        M Offline
        M4RZB4Ni
        wrote on 25 Aug 2016, 16:57 last edited by M4RZB4Ni
        #3

        @VRonin
        but folder is exist and image doese not save :|
        with this code i chek the path:

        void Medical_Records::createFolderPath()
        {
            QDir createfolder("D:\\Projects\\physiotherapy\\sickpic");
           if(!createfolder.exists())
             {
               createfolder.mkpath("D:\\Projects\\physiotherapy\\sickpic");
             }
        }
        vo
        
        1 Reply Last reply
        0
        • V Offline
          V Offline
          VRonin
          wrote on 25 Aug 2016, 17:02 last edited by
          #4

          2 questions:

          • does originalPixmap.isNull() return true?
          • what is the content of filename?

          "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
          ~Napoleon Bonaparte

          On a crusade to banish setIndexWidget() from the holy land of Qt

          M 1 Reply Last reply 25 Aug 2016, 17:07
          0
          • V VRonin
            25 Aug 2016, 17:02

            2 questions:

            • does originalPixmap.isNull() return true?
            • what is the content of filename?
            M Offline
            M Offline
            M4RZB4Ni
            wrote on 25 Aug 2016, 17:07 last edited by
            #5

            @VRonin
            1:qDebug dont show anything about it
            2:content is this :

                 QString filename = "asd.PNG";
            
            
            1 Reply Last reply
            0
            • V Offline
              V Offline
              VRonin
              wrote on 25 Aug 2016, 17:09 last edited by VRonin
              #6

              1: could you try Q_ASSERT(!originalPixmap.isNull()); (this should cause a "crash" in your application if the image is null)
              2: your are missing a / try also to specify the format: originalPixmap.save("D:/Projects/physiotherapy/sickpic/"+filename,"PNG");

              "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
              ~Napoleon Bonaparte

              On a crusade to banish setIndexWidget() from the holy land of Qt

              1 Reply Last reply
              1
              • M Offline
                M Offline
                M4RZB4Ni
                wrote on 25 Aug 2016, 17:19 last edited by
                #7

                thanks:)
                with this note:

                • 2: your are missing a / try also to specify the format: `originalPixmap.save("D:/Projects/physiotherapy/sickpic/"+filename,"PNG");*
                  Saving Problem Solved
                  But if i want to write a code to if picture exists show message and with yes/no
                  if user clicks on the yes overwrite pic
                  Thanks a lot:)
                1 Reply Last reply
                1
                • V Offline
                  V Offline
                  VRonin
                  wrote on 25 Aug 2016, 17:21 last edited by
                  #8
                  if(QFile::exists("D:/Projects/physiotherapy/sickpic/"+filename))
                  //ask
                  

                  "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
                  ~Napoleon Bonaparte

                  On a crusade to banish setIndexWidget() from the holy land of Qt

                  M 2 Replies Last reply 25 Aug 2016, 20:32
                  2
                  • V VRonin
                    25 Aug 2016, 17:21
                    if(QFile::exists("D:/Projects/physiotherapy/sickpic/"+filename))
                    //ask
                    
                    M Offline
                    M Offline
                    M4RZB4Ni
                    wrote on 25 Aug 2016, 20:32 last edited by
                    #9
                    This post is deleted!
                    1 Reply Last reply
                    0
                    • V VRonin
                      25 Aug 2016, 17:21
                      if(QFile::exists("D:/Projects/physiotherapy/sickpic/"+filename))
                      //ask
                      
                      M Offline
                      M Offline
                      M4RZB4Ni
                      wrote on 25 Aug 2016, 20:42 last edited by
                      #10

                      @VRonin
                      my problems Solved
                      Thank you very much my dear Friend :)

                      1 Reply Last reply
                      0

                      4/10

                      25 Aug 2016, 17:02

                      • Login

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