SystemUiButton

I compile error when I try to use SystemUiButton.

Seems that some libs aren't related.

What libs, I must add to the .pro file?

And generally the case, how do I know what libs should be linked?

Thanks in advance

Add this

LIBS +=-lbbsystem

Tags: BlackBerry Developers

Similar Questions

  • HOWTO: Translation Live in C++ similar to re-translate in QML

    WARNING: To come long post!

    If you've built (or building) your apps BlackBerry 10 Aboriginal stunts with internationalization in mind, then you have probably dotted with QML qsTr() calls and macros tr() C++ code. When your application starts the text wrapped in qsTr() or tr() is replaced by the localized text for the local unit and the language (if defined, otherwise default text is used). This works fine unless you change the language setting on your device while your application is running. Unless you take measures to propagate the change to the language through your live webcam app, the text displayed in your application will not match the settting of language new device only when your application is restarted. QML provides this translation of 'direct' with the re-translation class, which can be used with qsTr() update of translations that soon the language setting of the device is changed:

    Page {   Container {      Label {         id: label01
    
             // ---This label's text will be live translated         text: qsTr("Label 1") + Retranslate.onLanguageChanged      }      Label {         id: label02
    
             // ---This label's text will be static translated         text: qsTr("Label 2")      }   }}
    

    In this example, label01 will be his attribute of translated text live as it is updated as soon as the device language is changed. However, label02 will have only his attribute of text translated when the software is first started and the language changes following while the application is running will not update to it.

    With the help of the re-translation with QML class makes direct translation as simple as the addition of a small amount of code just after each use of qsTr(), but C++ does provide no such convenience. To implement the translation directly in C++ code, it is necessary to call setXXX() for a string with the macro tr() attribute slot once to do the initial translation and then connect the setXXX() slot to an instance of LocaleHandler that emits a signal every time the language (or locale) changes. It's complicated by the fact that the LocaleHandler knows that the language has changed, but he doesn't know which key text to provide openings, it is attached to the then must fix the LocaleHandler signal to an intermediate location that knows what translation of key to use for this attribute, and then emits a different signal with the key as a parameter that must be connected to the slot machine control setXXX() . This means that, for every single control attribute you want live, translate you'll need a separate intermediate location set somewhere, a signal linked to this site and two calls QObject::connect(). For EACH attribute that we want to live translation. Of course, this becomes very ugly, very fast.

    I prefer to use C++ with QML little or not to expose my app pages so I was determined to find a solution that was easier to use than retranslating in QML (or almost) and after some trial and error I came up with a solution that I am very satisfied. The core of this technique is a C++ class called LiveTranslator. The syntax to use is a bit more complicated to use QML re-translation, but as re-translation you only need to add a line of code for each attribute that you want to translate live. Here is the header for LiveTranslator:

    #ifndef LIVETRANSLATOR_HPP_
    #define LIVETRANSLATOR_HPP_
    
    #include 
    
    using namespace bb::cascades;
    
    class LiveTranslator: public QObject {
        Q_OBJECT
    
        QString _key;
        QString _context;
    
        static LocaleHandler* _localeHandler;
    
    public:
        LiveTranslator( const QString& context, const QString& key, QObject* target, const char* slot );
        static void setLocaleHandler( LocaleHandler* localeHandler );
    
    private slots:
        void localeOrLanguageChangedHandler();
    
    signals:
        void translate( const QString& string );
    };
    
    #endif /* LIVETRANSLATOR_HPP_ */
    

    .. .and the body...

    #include "LiveTranslator.hpp"
    
    // ---Initialize the locale handler pointer on app startup so we can tell if it has been set properly later
    LocaleHandler* LiveTranslator::_localeHandler = 0;
    
    // ---Note that the target control is also used as the parent so the live translator dies when the control does
    LiveTranslator::LiveTranslator( const QString& context, const QString& key, QObject* target, const char* slot ) :
            QObject( target ) {
    
        bool success;
        Q_UNUSED( success );
    
        // ---Save the context and key string
        this->_key = key;
        this->_context = context;
    
        // ---Die (during debug) if the locale handler hasn't been set properly before use
        Q_ASSERT( LiveTranslator::_localeHandler );
    
        // ---Watch for locale or language changes
        success = QObject::connect( LiveTranslator::_localeHandler, SIGNAL( localeOrLanguageChanged() ), SLOT( localeOrLanguageChangedHandler() ) );
        Q_ASSERT( success );
    
        // ---Trigger specified slot when locale or language changes
        success = QObject::connect( this, SIGNAL( translate( const QString& ) ), target, slot );
        Q_ASSERT( success );
    }
    
    void LiveTranslator::localeOrLanguageChangedHandler() {
        // ---Use the specified slot on the target to update the appropriate string attribute with the translated key
        emit translate( QCoreApplication::translate( this->_context.toLocal8Bit().constData(), this->_key.toLocal8Bit().constData() ) );
    }
    
    // ---This function MUST be called once with a valid LocaleHandler before any LiveTranslator classes are instantiated
    void LiveTranslator::setLocaleHandler( LocaleHandler* localeHandler ) {
        LiveTranslator::_localeHandler = localeHandler;
    }
    

    LiveTranslator encapsulates all the ugly stuff, including remembering the key to the translation, the intermediate signal/slot, and all signal/slot connections necessary for direct translation. Use is as simple as creating an instance of LiveTranslator, passing the constructor the translation for the attribute key (and the context, but more on that later), the Visual control of the target and the location on the control that accepts the update of translation. Note that tr() only works with static keys chains...

    // ---This is valid
    QString str1 = tr("string one");
    
    // ---This is not!
    Qstring str1 = "string one";
    QString str2 = tr(str1);
    

    .. .so instead tr(), LiveTranslator must use QCoreApplication translate() internally.

    An example of use of LiveTranslator :

    MyClass::MyClass() {
        Label* label = Label::create().text( tr("Label one") );
        new LiveTranslator( "MyClass", "Label one", label, SLOT(setText(const QString&)));
    
        Option* option = Option::create().text( tr("Option one") ).description( tr("Option one description") );
        new LiveTranslator( "MyClass", "Option one", option, SLOT(setText(const QString&)));
        new LiveTranslator( "MyClass", "Option one description", option, SLOT(setDescription(const QString&)));
    
        ActionItem* actionItem = Option::create().title( tr("Action one") );
        new LiveTranslator( "MyClass", "Action one", actionItem, SLOT(setTitle(const QString&)));
    }
    

    Note that there is no need to save a reference to the new instance LiveTranslator since the constructor sets the 'target' as a parent control. When the control is destroyed by your app the LiveTranslator will go with him. The first parameter to the constructor LiveTranslator is the 'context' where the translation key. When you use the macro tr() (or function qsTr() QML) the code parser mentions of where he found the key and stores it in the translation file. This way you can use the same key for translation on different pages, and if the context is different, you could have them translated differently. The parser doesn't know anything about the LiveTranslator class but it must indicate the context explicitly. For C++, the context is always the name of the class containing the code that you are translating. In addition, in case it is not obvious, the "key" parameter must be the same value used with tr() on the input line.

    There is one thing that you must do before using LiveTranslator in your C++ code and that is to give it a LocaleHandler to work with. Rather than force you to spend a LocaleHandler for each instance of LiveTranslator, you tell LiveTranslator that one to use only once with a static function call. If you created your application from one of the Momentics models then you already have a Manager, you can use:

    ApplicationUI::ApplicationUI() : QObject() {
        // prepare the localization
        m_pTranslator = new QTranslator( this );
        m_pLocaleHandler = new LocaleHandler( this );
    
        // Use this locale handler for all the live translations too
        LiveTranslator::setLocaleHandler( m_pLocaleHandler );
    
        ...
        ...
        ...
    }
    

    I enclose the source for LiveTranslator so all you need to do to get the direct translation working in your BB10 native C++ code is extract the zip in your src directory, add a call to LiveTranslator::setLocaleHandler() in your main application class constructor, and then call new LiveTranslator (...) with the appropriate settings for each attribute of the control you want to be living translated. I hope that is useful to the native BlackBerry 10 development community wonderful (and long-suffering).

    IMPORTANT!

    The instructions posted above have been extended and improved to work with some additional user interface controls such as SystemDialog and SystemUiButton. It was published with a link to a sample application on GitHub as an guest article on the Blog of Dev of BlackBerry. Additional functionality has been added to the original code shown above, then the blog article and GitHub example now consider the definitive description of this technique.

    See you soon.

  • NotificationsDialog returns the same value for the two buttons

    I have a NotificationsDialog with two SystemUiButtons, now when I click on buttons and console the result they both return the number two, I don't really understand why.

    {NotificationDialog}
    ID: alertdialog
    Title: "Alarm" - + alarmTime
    body: Setting.get ("alarmCompletedMessage")
    repeat: true
                
                    
    buttons:]
    {SystemUiButton}
    label: "Stop".
    },
    {SystemUiButton}
    label: "Snooze."
    }
    ]
    onFinished: {}
    Console.log ('result' + result)
    Console.log (Error)
    }
    }

    Is there a better way to identify which button has been activated?

    Wish a little, she supported confirm and Cancel buttons, or SystemUIButtons have their own onClicked properties

    Thank you

    Use buttonSelection () instead of the result .label

  • Invoke the App UI of Headless on click of a button

    Hello

    I want to open the part of the user interface of my app on click of a button of my notification dialog of headless.

    can anyone help me please with this problem.

    Thank you & best regards

    Here you go

    bb::system::InvokeRequest request;
        request.setTarget("com.example.headlessdialog");
        request.setAction("bb.action.START");
        bb::system::SystemUiButton *but = new bb::system::SystemUiButton("Ok");
        NotificationDialog *nd = new NotificationDialog();
        nd->appendButton(but, request);
        nd->setParent(this);
        nd->setTitle("Headless Dialog!");
        nd->setBody("I'm a headless dialog!");
        nd->show();
    
  • Cannot get NavigationDialog to show.

    I have this code in a simple app... purpose of HelloCascades the dialog box does not appear.  No idea what I'm missing?  Thank you.

    NotificationDialog *notification = new NotificationDialog(this);
        notification->setTitle("TEST");
        notification->setBody("THIS IS THE BODY");
        SystemUiButton *yesButton = new SystemUiButton("Yes");
        SystemUiButton *noButton = new SystemUiButton("No");
        notification->appendButton(yesButton);
        notification->appendButton(noButton);
        notification->show() ;
    

    Your sample works very well since QML.  I saw the difference in the projects.  I didn't know that I had to set the permission for "Post notification".  Thanks for the help.

  • How to get the text of a SystemPrompt (Cascades)

    Hello

    I've been struggling with this for a few hours now. I followed the example of "dialogues" on github, so I have successfully created a SystemPrompt (the dialog box that allows the user to enter text and accept / reject). Curiously, in this example there is no use of user text input. Do you know how to get the text in my QML? Here you have an example of code that I use:

    My QML:

    // Default empty project template
    import bb.cascades 1.0
    import bb.system 1.0
    
    // creates one page with a label
    NavigationPane {
        id: navigationPane
        Page {
            attachedObjects: [
                SystemPrompt {
                    id: prompt
                    title: qsTr("Enter a text for the label")
                    modality: SystemUiModality.Application
                    inputField.inputMode: SystemUiInputMode.Default
                    inputField.emptyText: "Label text..."
                    confirmButton.label: qsTr("Ok")
                    confirmButton.enabled: true
                    cancelButton.label: qsTr("Cancel")
                    cancelButton.enabled: true
                    onFinished: {
                        if (result == SystemUiResult.ConfirmButtonSelection) {
                            lab1.text = ????? // Here is where I don't know what to do
                        }
                    }
                }
            ]
    
            Container {
                layout: StackLayout {}
    
                Label {
                            id: lab1              text: "Label text"
                    objectName: "lab1"
                    textStyle.base: SystemDefaults.TextStyles.TitleText
                    horizontalAlignment: HorizontalAlignment.Center
                }
    
                Button {
                    text: "Update label"
                    horizontalAlignment: HorizontalAlignment.Center
                    topMargin: 150.0
                    onClicked: {
                        //_appUi.editLabel();
                        prompt.show();
                    }
                }
            }
        }
    }
    

    Be sure to add this in your .cpp file or all of app:

    #include 
    #include 
    #include 
    #include 
    #include 
    #include 
    #include 
    #include 
    #include 
    #include 
    

    and don't forget to include them in your app .cpp file (probably not all are needed, but just in case I leave here for the moment):

    qmlRegisterType("bb.system", 1, 0, "SystemUiButton");
        qmlRegisterType("bb.system", 1, 0, "SystemUiInputField");
        qmlRegisterType("bb.system", 1, 0, "SystemToast");
        qmlRegisterType("bb.system", 1, 0, "SystemPrompt");
        qmlRegisterType("bb.system", 1, 0, "SystemCredentialsPrompt");
        qmlRegisterType("bb.system", 1, 0, "SystemDialog");
        qmlRegisterUncreatableType("bb.system", 1, 0, "SystemUiError", "");
        qmlRegisterUncreatableType("bb.system", 1, 0, "SystemUiResult", "");
        qmlRegisterUncreatableType("bb.system", 1, 0, "SystemUiPosition", "");
        qmlRegisterUncreatableType("bb.system", 1, 0, "SystemUiInputMode", "");
        qmlRegisterUncreatableType("bb.system", 1, 0, "SystemUiModality", "");
        qRegisterMetaType("bb::system::SystemUiResult::Type");
    

    Thank you very much

    If you look very carefully by the docs, you'll trip over https://developer.blackberry.com/cascades/reference/bb__system__systemprompt.html#inputfieldtextentr...

    So, replace your? with inputFieldTextEntry() and you will get the text you need.

  • Need help on the Notification dialog box

    I'm vascular trouble with the notification dialog box:-I can not understand how to connect the signal of SystemUiButton - are added to the Qt code notification dialog box, I have two button in the dialog box.

    -Are there a way to disable the sound notification and led when the dialog box shows?

    Help thank you enemies

    Using only QML?  Have you checked the sample application for Notifications in the list of platform here?

    https://developer.BlackBerry.com/Cascades/sampleapps/

    If you use QML:

    You would use onFinished: {} for the NotificationDialog that you specify in the attachedObjects area to get signal...

        onFinished: {        if (result == 2)            console.log("SUI: " + notificationDialog.buttonSelection().label)    }
    

    To find out which button has been selected according to the label you provided...

    If you are using C++:

    Connect the signal with a member to the NotificationDialog variable, you declare and:

    // Be sure to include the SystemUiButton and NotificationResult stuff
    #include 
    #include 
    ...
    ...
    
        bool res = connect(myNotDialog,
              SIGNAL(finished(bb::platform::NotificationResult::Type),
              this,
              SLOT(onFinished(bb::platform::NotificationResult::Type)));
        Q_ASSERT(res);
        Q_UNUSED(res);
    
    // In your SLOT function you would check the result...
    
    void myClass::onFinished(bb::platform::NotificationResult::Type result)
    {
        if (result == NotificationResult::ButtonSelection) {
            if (myNotDialog->buttonSelection()->label() == "Okay") {
                // User clicked Okay
                // And you check any other button labels you have..        }
        }
    }
    

    Not 100% sure, but that's the idea...

    -Edit-

    Used the wrong include areas...

    In addition, I'm not quite sure, you can turn off the stuff of notification in your application. I know that the user can in the settings-> notification... but obviously that doesn't help you much...... You can try to use the resetCategory() function, which assigns a QString::null, meaning no category... Not quite sure if this is what is happening...

    And possibly using setSoundUrl(""); but not sure if it would give an error...

  • How to connect NotificationDialog finished() signal?

    Can't find a doc on how to correctly connect the signal over.

    I have this for the notificationdialog in my c folder

    Boolean success = QObject::connect (pNotification,
    SIGNAL (finished (bb:latform::NotificationResult:ButtonSelection *));
    This,
    SLOT (onSelected (bb:latform::NotificationResult::ButtonSelection*)));))

    sub myApp:nSelected (bb:latform::NotificationResult * button)
    {
    }

    I have this in my file:

    public Q_SLOTS:
    Sub onSelected (bb:latform::NotificationResult * button);

    What is the right way to connect it?  Thank you

    To give a clear answer:

    #include 
    using namespace bb::platform;
    
    NotificationDialog *pNotification = .....;
    
    [...]QObject::connect(pNotification, SIGNAL(finished(bb::platform::NotificationResult::Type)),
                         this, SLOT(onSelected(bb::platform::NotificationResult::Type));
    
    [...]
    
    void myApp::onSelected(bb::platform::NotificationResult::Type value){
    NotificationDialog *dialog = qobject_cast(sender()); // or reference a member variable directly
    if (dialog)
    {
      SystemUiButton *button = dialog->buttonSelection();
      ...
    }
    
  • QML custom dialog box

    I want to make a dialog custom with 3 buttons, I know c ++ can do this, but I want to do in QML? someone knows how to do?

    You can use the buttons

    example:

    SystemDialog {
        id: dialog
        title: "Title"
        body: "body body body body body body"
        buttons: [
            SystemUiButton {
                label: "One"
            },
            SystemUiButton {
                label: "Two"
    
            }
        ]
    }
    

    If you want to delete buttons cancel or confirm, fair value label empty (null) string.

    You can watch the sample app

    https://developer.BlackBerry.com/native/sampleapps/ + Dialogues

    CustomDialogs

    https://developer.BlackBerry.com/native/documentation/Cascades/UI/dialogs_toasts/custom_dialogs.html

Maybe you are looking for