Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
New Developer
Posts: 15
Registered: ‎09-07-2013
My Device: BlackBerry Z30 STA-100-2
My Carrier: Vodafone UK

Re: Saving settings

Alright, I tried changing app to _app and it worked without errors...until I pressed the buttons on my device screen.

 

The console log said 

When saving

"asset:///main.qml:11: TypeError: Result of expression '_app.save' [undefined] is not a function."

When loading

"asset:///main.qml:21: TypeError: Result of expression '_app.read' [undefined] is not a function."

 

I updated my code in the previous post to match what I changed it to just now.

Developer
Posts: 6,152
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30
My Carrier: Orange

Re: Saving settings

Can you post the header.

Have you defined those functions as Q_INVOKABLE?

If you've been helped click on Like Button, if you've been saved buy the app. Smiley Happy

Developer of stokLocker, Sympatico and Super Sentences.
New Developer
Posts: 15
Registered: ‎09-07-2013
My Device: BlackBerry Z30 STA-100-2
My Carrier: Vodafone UK

Re: Saving settings

Whoops, here it is 

/*
 * Copyright (c) 2011-2014 BlackBerry Limited.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef ApplicationUI_HPP_
#define ApplicationUI_HPP_

#include <QObject>

namespace bb
{
    namespace cascades
    {
        class LocaleHandler;
    }
}

class QTranslator;

/*!
 * @brief Application UI object
 *
 * Use this object to create and init app UI, to create context objects, to register the new meta types etc.
 */
class ApplicationUI : public QObject
{
    Q_OBJECT
public:
    Q_INVOKABLE void save(QString key, QString value);
    Q_INVOKABLE QString read(QString key);
    ApplicationUI();
    virtual ~ApplicationUI() {}
private slots:
    void onSystemLanguageChanged();
private:
    QTranslator* m_pTranslator;
    bb::cascades::LocaleHandler* m_pLocaleHandler;
};

#endif /* ApplicationUI_HPP_ */

 

New Developer
Posts: 15
Registered: ‎09-07-2013
My Device: BlackBerry Z30 STA-100-2
My Carrier: Vodafone UK

Re: Saving settings

Fixed it!

 

I re-typed the code that I had copy/pasted in (since the beta 2.1 Momentics seems to hate copy/pasting)

 

Then realised I had missed a colon! All this for just a missing symbol eh?

 

Q_INVOKABLE : void  save(QString key, QString value);

 Thanks for the help both of you Smiley Happy

Developer
Posts: 6,152
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30
My Carrier: Orange

Re: Saving settings

As long as you got there in the end.

 

By the way looking back at your postings you seem to be confusing likes and solutions, use the 'mark as solved' option to mark your OP as answered use likes just to say thanks for helping or for posts you like. Smiley Happy

 

You may want to read this...

 

http://supportforums.blackberry.com/t5/Native-Development/Get-the-Most-Out-of-the-BlackBerry-Develop...


If you've been helped click on Like Button, if you've been saved buy the app. Smiley Happy

Developer of stokLocker, Sympatico and Super Sentences.