Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Saving image to QSettings from QML
Forum Updated to NodeBB v4.3 + New Features

Saving image to QSettings from QML

Scheduled Pinned Locked Moved QML and Qt Quick
10 Posts 4 Posters 6.3k 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.
  • S Offline
    S Offline
    strekazoid
    wrote on last edited by
    #1

    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
    0
    • A Offline
      A Offline
      andre
      wrote on last edited by
      #2

      -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
      0
      • G Offline
        G Offline
        goetz
        wrote on last edited by
        #3

        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
        0
        • S Offline
          S Offline
          strekazoid
          wrote on last edited by
          #4

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

          1 Reply Last reply
          0
          • A Offline
            A Offline
            andre
            wrote on last edited by
            #5

            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
            0
            • S Offline
              S Offline
              strekazoid
              wrote on last edited by
              #6

              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
              0
              • S Offline
                S Offline
                strekazoid
                wrote on last edited by
                #7

                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
                0
                • A Offline
                  A Offline
                  andre
                  wrote on last edited by
                  #8

                  [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
                  0
                  • S Offline
                    S Offline
                    strekazoid
                    wrote on last edited by
                    #9

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

                    Agree :D

                    1 Reply Last reply
                    0
                    • K Offline
                      K Offline
                      KA51O
                      wrote on last edited by
                      #10

                      Have you tried QDataStream to save the image ?

                      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