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


Thank you for visiting the BlackBerry Support Community Forums.

BlackBerry will be closing the BlackBerry Support Community Forums Device Forums on April 1st (Developers, see below)

BlackBerry remains committed to providing excellent customer support to our customers. We are delighted to direct you to the CrackBerry Forums, a well-established and thorough support channel, for continued BlackBerry support. Please visit http://forums.crackberry.com or http://crackberry.com/ask. You can also continue to visit BlackBerry Support or the BlackBerry Knowledge Base for official support options available for your BlackBerry Smartphone.

"When we launched CrackBerry.com 10 years ago, we set out to make it a fun and useful destination where BlackBerry Smartphone owners could share their excitement and learn to unleash the full potential of their BlackBerry. A decade later, the CrackBerry community is as active and passionate as ever and I know our knowledgeable members and volunteers will be excited to welcome and assist more BlackBerry owners with their questions."

- Kevin Michaluk, Founder, CrackBerry.com

Developers, for more information about the BlackBerry Developer Community please review Join the Conversation on the BlackBerry Developer Community Forums found on Inside BlackBerry.


Reply
Highlighted
Developer
Posts: 262
Registered: ‎07-13-2012
My Device: PlayBook, DA B, DA C, LE Z10 #102, Q10, Z30
My Carrier: T-Mobile

Re: Running C++ script using QML UI?

 

To upload your file, zip the project (so all the folders are in one file) and use the attachments to the right of the dialog box for replying (red circle in image below):

 

AttachBBForum.png

 

Or feel free to email it to me at bcs925@yahoo.com

 

I would really like to see what you did because I tried to do exactly what you described but I get build errors.  My plan once all this is straightened out is to write up a tutorial explaining each piece so anyone else in my shoes can reference my example with full explanations of every step.  Thanks again for your help.

 

 

---
Check out my BB10 Cascades Coding site: BBcascades.com & Cascades Blog: bbcascadescode.tumblr.com

My Built for BlackBerry app: The Dive Plan
Developer
Posts: 262
Registered: ‎07-13-2012
My Device: PlayBook, DA B, DA C, LE Z10 #102, Q10, Z30
My Carrier: T-Mobile

Re: Running C++ script using QML UI?

Thanks again to everyone that helped me with this, especially AllSystemGo who was a HUGE help

 

In case others were curious here's the code that ended up working (and is pretty easy to follow now that I see the solution)...

 

app.hpp:

#ifndef APP_H
#define APP_H

#include <QtCore/QObject>
#include <QtCore/QMetaType>

#include <bb/cascades/Event>
#include <bb/cascades/UiObject>
#include <bb/cascades/Control>
#include <QObject>


class App: public QObject {

Q_OBJECT


public:
App();

Q_INVOKABLE QString clickedButton(int in1, int in2);

};

#endif // ifndef APP_H

 app.cpp:

#include <bb/cascades/Application>
#include <bb/cascades/QmlDocument>
#include <bb/cascades/AbstractPane>

#include "app.hpp"

using namespace bb::cascades;

App::App() {

    QmlDocument *qml = QmlDocument::create("main.qml");
    qml->setContextProperty("app", this);

    AbstractPane *root = qml->createRootNode<AbstractPane>();
    Application::setScene(root);
}

QString App::clickedButton(int in1, int in2)
{
QString reading;

    if (in1 == 1 && in2 == 1)
    	reading = 'A';
    else if (in1 == 1 && in2 == 2)
    	reading = 'B';
    else if (in1 == 1 && in2 == 3)
    	reading = 'C';
    else if (in1 == 2 && in2 == 1)
    	reading = 'D';
    else if (in1 == 2 && in2 == 2)
    	reading = 'E';
    else if (in1 == 2 && in2 == 3)
    	reading = 'F';
    else if (in1 == 3 && in2 == 1)
    	reading = 'G';
    else if (in1 == 3 && in2 == 2)
    	reading = 'H';
    else if (in1 == 3 && in2 == 3)
    	reading = 'I';

        return reading;

}

 main.qml:

import bb.cascades 1.0

Page {
    content: Container {
        layout: StackLayout {
        }
        ImageView {
            id: imageViewID
            imageSource: "asset:///images/Table_Example.jpg"
        }
        DropDown {
            id: in1
            objectName: "in1"
            title: "Vertical Value?"
            selectedIndex: SelectedIndexNone
            onSelectedIndexChanged: {
                var option = in1.at(in1.selectedIndex).value;
              
                if (in2.selectedIndex == -1 ) {
                    var option2 = 0
                }
                else {
                    var option2 = in2.at(in2.selectedIndex).value;
                }

                total.text = app.clickedButton(option, option2);
            }
            Option {
                text: "1"
                value: 1
            }
            Option {
                text: "2"
                value: 2
            }
            Option {
                text: "3"
                value: 3
            }
        }
        DropDown {
            id: in2
            objectName: "in2"
            title: "Horizontal Value?"
            //selectedIndex: 0
            onSelectedIndexChanged: {
               var option2 = in2.at(in2.selectedIndex);
                
                if (in1.selectedIndex == -1 ) {
                    var option = 0
                }
                else {
                    var option = in1.at(in1.selectedIndex);
                }

                total.text = app.clickedButton(option.value, option2.value);
            } //have my C++ run here
            Option {
                text: "1"
                value: 1
            }
            Option {
                text: "2"
                value: 2
            }
            Option {
                text: "3"
                value: 3
            }
        }
        Label {
            id: total
            objectName: "total"
            text: ""
        }
    }
}

 

 

---
Check out my BB10 Cascades Coding site: BBcascades.com & Cascades Blog: bbcascadescode.tumblr.com

My Built for BlackBerry app: The Dive Plan