Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-56436

saveToFile() does not accept url with protocol

    XMLWordPrintable

Details

    • All
    • 38cb0e9a74bf44413590b96767773b3138ad6666 (qt/qtdeclarative/dev)

    Description

      On OS X, the following code fails:

      FileDialog {
          folder: shortcuts.documents
          selectExisting: false
          onAccepted: {
              content.grabToImage(function(result){
                  if (!result.saveToFile(fileUrl)){
                    console.error('Unknown error');
                  }
              });
          }
      }
      

      The workaround is to convert the fileUrl to a string, and remove the protocol:

      FileDialog {
          folder: shortcuts.documents
          selectExisting: false
          onAccepted: {
              var urlNoProtocol = (fileUrl+"").replace('file://','');
              content.grabToImage(function(result){
                  if (!result.saveToFile(fileNoProtocol)){
                    console.error('Unknown error saving',fileNoProtocol);
                  }
              });
          }
      }
      

      Related Stack Overflow question: http://stackoverflow.com/q/39939565/405017

      Attachments

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              srutledg Shawn Rutledge
              phrogz Gavin Kistner
              Votes:
              2 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes