Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Saving image to QSettings from QML

    QML and Qt Quick
    4
    10
    5126
    Loading More Posts
    • 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.
    • S
      strekazoid last edited by

      I'm using QSettings for storing user settings locally. QSettings are exposed to QML via wrapper:
      http://developer.qt.nokia.com/forums/viewthread/11696/

      QSettings support QImage as an argument for saving setting. How I can save image to QSettings from QML? Providing Image element returns me error:

      QVariant::save: unable to save type 136.

      1 Reply Last reply Reply Quote 0
      • A
        andre last edited by

        -QSettings does not support saving images.- Could you get away with just saving an image name instead, and save the image itself separately?

        Edit: I stand corrected. QSettings docs states that it does support QImages.

        1 Reply Last reply Reply Quote 0
        • G
          goetz last edited by

          The API docs state different:

          bq. QSettings's API is based on QVariant, allowing you to save most value-based types, such as QString, QRect, and QImage, with the minimum of effort.

          I never tried it myself, though. It may be a restriction of the QML stuff?

          http://www.catb.org/~esr/faqs/smart-questions.html

          1 Reply Last reply Reply Quote 0
          • S
            strekazoid last edited by

            Yes, I basically wonder if it is possible to construct QImage from QML and save it to QSettings?

            1 Reply Last reply Reply Quote 0
            • A
              andre last edited by

              I don't think you can do that from QML, as QML does not allows you access to the underlying QImage, AFAIK.

              1 Reply Last reply Reply Quote 0
              • S
                strekazoid last edited by

                Doing some experiments by capturing image with Camera and trying to save it into Settings.

                @Camera {
                id: camera
                x: 0
                y: 0
                anchors.fill: parent
                focus: visible //to receive focus and capture key events
                captureResolution : "640x480"

                        flashMode: Camera.FlashAuto
                        whiteBalanceMode: Camera.WhiteBalanceAuto
                
                        onImageCaptured : {
                            captureButton.text = "Captured"
                            image1.source = preview
                            text1.text = preview
                            Settings.setValue("image", preview)
                        }@
                

                Getting this:

                [Qt Message] QVariant::load: unable to load type 136.
                [Qt Message] QVariant::save: unable to save type 136.

                I guess I have to implement some sort of image handler in C++ side for saving captured images.

                1 Reply Last reply Reply Quote 0
                • S
                  strekazoid last edited by

                  How about if I need to create QImage from QML Image element? Same thing like discussed here but backwards? I'm currently capturing image with QML Camera, and would like to save it somehow.

                  1 Reply Last reply Reply Quote 0
                  • A
                    andre last edited by

                    [quote author="strekazoid" date="1321969152"]How about if I need to create QImage from QML Image element? Same thing like discussed here but backwards? I'm currently capturing image with QML Camera, and would like to save it somehow.[/quote]

                    I have moved the message above from "this old topic":http://developer.qt.nokia.com/forums/viewthread/11832/ to here. Strekazoid, please confine the discussion of your issue to a single topic. You already have multiple topics open on different aspects of this same issue. Posting in even more topics, even if they are related, doesn't help.

                    1 Reply Last reply Reply Quote 0
                    • S
                      strekazoid last edited by

                      bq. Posting in even more topics, even if they are related, doesn’t help.

                      Agree :D

                      1 Reply Last reply Reply Quote 0
                      • K
                        KA51O last edited by

                        Have you tried QDataStream to save the image ?

                        1 Reply Last reply Reply Quote 0
                        • First post
                          Last post