Saving image to QSettings from QML



  • 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.



  • -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.



  • 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?



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



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



  • 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.



  • 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 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.



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

    Agree :D



  • Have you tried QDataStream to save the image ?


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.