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
Forum Updated to NodeBB v4.3 + New Features

SAVE AND LOAD image in Directory

Scheduled Pinned Locked Moved Solved General and Desktop
10 Posts 2 Posters 5.4k Views 1 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.
  • M4RZB4NiM Offline
    M4RZB4NiM Offline
    M4RZB4Ni
    wrote on 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
    • VRoninV Offline
      VRoninV Offline
      VRonin
      wrote on 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

      M4RZB4NiM 1 Reply Last reply
      0
      • VRoninV VRonin

        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

        M4RZB4NiM Offline
        M4RZB4NiM Offline
        M4RZB4Ni
        wrote on 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
        • VRoninV Offline
          VRoninV Offline
          VRonin
          wrote on 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

          M4RZB4NiM 1 Reply Last reply
          0
          • VRoninV VRonin

            2 questions:

            • does originalPixmap.isNull() return true?
            • what is the content of filename?
            M4RZB4NiM Offline
            M4RZB4NiM Offline
            M4RZB4Ni
            wrote on 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
            • VRoninV Offline
              VRoninV Offline
              VRonin
              wrote on 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
              • M4RZB4NiM Offline
                M4RZB4NiM Offline
                M4RZB4Ni
                wrote on 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
                • VRoninV Offline
                  VRoninV Offline
                  VRonin
                  wrote on 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

                  M4RZB4NiM 2 Replies Last reply
                  2
                  • VRoninV VRonin
                    if(QFile::exists("D:/Projects/physiotherapy/sickpic/"+filename))
                    //ask
                    
                    M4RZB4NiM Offline
                    M4RZB4NiM Offline
                    M4RZB4Ni
                    wrote on last edited by
                    #9
                    This post is deleted!
                    1 Reply Last reply
                    0
                    • VRoninV VRonin
                      if(QFile::exists("D:/Projects/physiotherapy/sickpic/"+filename))
                      //ask
                      
                      M4RZB4NiM Offline
                      M4RZB4NiM Offline
                      M4RZB4Ni
                      wrote on last edited by
                      #10

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

                      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