SystemToast onTriggered?

Hi, how I trigger something when you press a button on SystemToast?

I don't know how to say.

Anythought please?

SystemToast * toast = new SystemToast (0);

Toast-> setBody ("Success.");
Toast-> button()-> setLabel ("Ok");
Toast-> show();

Connect you to the signal of finished() after creation, this thread has an example:

http://supportforums.BlackBerry.com/T5/Cascades-development/finished-signal-for-a-system-toast/m-p/2...

Some other value parent class of SystemToast on creating, for example new SystemToast (this).

In this way it will be destroyed when the parent is destroyed.

You might also want to destroy in the onFinished() slot as well. This can be done like this:

void YourClass::onFinished(bb::system::SystemUiResult::Type uiResult){
  ... process the result ...  SystemToast *toast = qobject_cast(sender());
  toast->deleteLater();
}

Otherwise the instance will continue to exist and will be destroyed only when its parent is destroyed.

Tags: BlackBerry Developers

Similar Questions

  • onTriggered retail Info (LISTVIEW)

    Hello

    Sorry to ask again

    I want to show the details of my promo

    It's my main QML

    NavigationPane {
               id : nav1
               onPopTransitionEnded: page.destroy()
            Page {
    
                Container {
                    Header{
                        title: "Promo"
                    } 
    
                    ListView {
                        id: listViewDemo
                        dataModel: GroupDataModel {
                            id : prm1
                            grouping: ItemGrouping.None
                        }
                        listItemComponents: [
                            ListItemComponent {
                                type: "promo"
                                Container {
                                    layout: StackLayout {
                                        orientation: LayoutOrientation.LeftToRight
                                    }
                                    WebView {
                                        preferredWidth: 150
                                        preferredHeight: 90
                                        verticalAlignment: VerticalAlignment.Top
                                        url : ListItemData["ImageLink"]
    
                                    }
                                    StandardListItem {
                                        title: ListItemData["promoID"] + "." + ListItemData["Title"]
                                        description: ListItemData["Description"]
                                        leftMargin: 30
                                        verticalAlignment: VerticalAlignment.Center  
    
                                        }
    
                                 }
                              }
                        ]  
    
                        function itemType(data, indexPath) {
                            return "promo";
                    }
    
                    onTriggered: {
                        if(indexPath!=0){
                            var promo = prm1.data(indexPath);
                            var promodetail = promocontent.createObject();
                            promodetail.promo = promo;
                            nav1.push(promocontent);
                        }
                    }
                    }
                    }
                 }
             }
    
                attachedObjects: [
                    DataSource {
                        id: serviceDataSource
                        source:                                  "http://www.rws.rajaspot.com/rs_promoclient.php"
                        type: DataSourceType.Json
                        onDataLoaded: {
                        listViewDemo.dataModel.insertList(data.promo_info)
                        }
                    },
                    ComponentDefinition {
                        id : promocontent
                        source : "PromoContent.qml"
                    }
                ]
    
                onCreationCompleted: {
                    serviceDataSource.load();
                }
    

    It's my promodetail

    Page {
        property variant promo;
        Container {
    
            id: container1
            verticalAlignment: VerticalAlignment.Center
            horizontalAlignment: HorizontalAlignment.Center
            topPadding: 50
            WebView {
    
                id : imageview
                horizontalAlignment: HorizontalAlignment.Center
                url: promo["ImageLink"]
                preferredWidth: 400
                preferredHeight: 400
            }
            Label {
    
                id:label1
                textStyle.base: SystemDefaults.TextStyles.BigText
                horizontalAlignment: HorizontalAlignment.Center
                text:promo["Title"]
            }
            Label {
                id:label2
                textStyle.base: SystemDefaults.TextStyles.SubtitleText
                horizontalAlignment: HorizontalAlignment.Center
                text:promo["Description"]
            }
        }
    }
    

    the following error message are

    url: promo["ImageLink"]
    
    text:promo["Title"]
    
    text:promo["Description"]
    

    He can't call my main.qml

    any suggestion?

    Thank you

    In some cases, your promo property can be "undefined" after you press page. Because it is not yet assigned. You can avoid this if you check the property on your page.
    For example:

    Page{
        property variant promo: null
    
        Container{
            layout: DockLayout{}
            leftPadding: 20
            rightPadding: 20
            topPadding: 20
    
            Label{
                id: label
                horizontalAligment: HorizontalAligment.Center
                /* In some cases will be the text empty. Because promo property is not yet assigned*/
                text: promo.Description
            }
        }
    }
    

    -------------------------------------------------
    See the simple example. You have two options to avoid ownership promo "undefined".
    1. replace the text property of the label with this
    text: promo? Promo. Description:
    2. signal property promo label definition
    onPromoChanged: if (promo) label.text = promo. Description

    My English is bad, so I hope you understand what I mean. Maybe someone who has good English can specify my 'answer '.

    EDIT:

    You can also find 'Data passing between the QML pages' for more information

  • topic of onTriggered in listview

    Hello

    I need to

    I have a listview on the list of all my image

    It's my listitemcomponent:

    WebView {
         id :web
         preferredWidth: 200
         preferredHeight: 150
         url : ListItemData.imageThumbnailURL
    }
    
    onTriggered: {
                    clearSelection()
                    select(indexPath)
                    var item = dataModel.data(indexPath)
                    if (item){
                        //What should i do here?
                    }
                }
    

    It's my webview that the bigone

                WebView{
                    id : itemimage
                    //url : image ? image["imageThumbnailURL"] : ""
                }
    

    It is what should show

    the small images located on the right side is my: listitemcomponent

    the big picture which is on the left side is WebView

    If I hit one of my list on the right, it will automatically go to enlarge

    What should I do in 'onTriggered '?

    Thank you

    You can change the URL used by your WebView something like this:

    itemimage.url = item.whateverVariableHoldsTheURL
    
  • ActionItem and SystemToast

    Hi guys,.

    I wonder, how to make an application (one on the top) with actionItem menu which shows SystemToast on triggered (in C++).  (Not much in C++, be so kind

    So far, I've done this, but I don't know what I'm missing?

    In main.cpp:

    void App::showToast() {
        SystemToast *toast = new SystemToast(this);
        toast->setBody("bla bla bla");
        toast->show();
    }
    
    void App::handleAction()
    {
            showToast();
    
    }
    
    int main(int argc, char **argv)
    {
        Application app(argc, argv);
        QmlDocument *qml = QmlDocument::create("asset:///main.qml").parent(&app);
        AbstractPane *root = qml->createRootObject();
        app.setScene(root);
    
        Menu *menu = new Menu;
                        ActionItem *actionOne = ActionItem::create()
                                                .title("About");
                        menu->addAction(actionOne);
                        Application::instance()->setMenu(menu);
        bool res = QObject::connect(actionOne, SIGNAL(triggered()), menu, SLOT(handleAction()));
        Q_ASSERT(res); // when this is uncomented application doesn't start
        Q_UNUSED(res);
    
        return Application::exec();
    
    }
    

    When this line is décommentée, application does not start.

    Q_ASSERT(res);
    

    In App.hpp:

    void showToast();
    public slots:
        void handleAction();
    

    OK, I managed to solve it. All the time, I was working in main.cpp, everything moved to App.cpp, and finally it works.

  • The default value of block SystemToast after setWallpaper

    Hello

    Every time I call bb/platform/HomeScreen.setWallpaper via QML and the call succeeds, a default value for SystemToast is shown with the text "photo set as wallpaper." It's pretty much the same that appears when you change the wallpaper via the settings > display.

    When I show a SystemToast with a different message right after calling setWallpaper, two notifications appear both on the other. If you see carefully the attached screen you can see my custom behind the default notification message.

    How can I stop this from happening?

    OS version 10.2.1.1055, using the SDK 10.2.1 gold.

    See you soon.

    I'm not sure that you would be able to prevent the system, but you can postpone your one or change its position...

    http://developer.BlackBerry.com/native/reference/Cascades/bb__system__systemtoast.html#property-posi...

  • ListView Access of ListItemComponent context action onTriggered model

    Consider following piece of code:

                ListView {
                    id: listView
                    dataModel: model
                    listItemComponents: ListItemComponent {
                        content: StandardListItem {
                            title: ListItemData.name
                            contextActions: ActionSet {
                                actions: ActionItem {
                                    title: "Delete"
    
                                    onTriggered: {
                                        //ListItem.view.model .... doesn't work
                                    }
                                }
                            }
                        }
                    }
                 }
            }
    

    When the user chooses to delete a line, I would like to access the listview model and remove the line given. But I can't get my hands on the model (as it is now defined as attached property).

    Docs say:

    ListItem.view - The ListView in which this item is visible. The item is in a context separate from the ListView, so any symbols from the ListView context that are to be accessible from items must be placed as dynamic properties on the ListView
    

    But to be honest I don't understand what I need to do to make it work (ie. have access to the parent listView.

    Any help would be greatly appreciated.

    Oh, I would do this without falling back into C++ code. I know how to solve this problem with c ++.

    Thank you

    You must reference it in your ListItemComponent ListItem:

    myItem.ListItem.view.dataModel
    
  • To access the instance of the ListView onTriggered event ListItemComponent

    Hello

    I'm pulling out my hair with this!

    I have a ListItemComponent in my ListView, and I want to access the component instance in the onTriggered of my ListView. I have the row, but I can't work on how to find the actual view.

    Simple example:

    {To ListView

    ID: myListView

    dataModel: myDataModel

    layout: {FlowListLayout}
    listItemComponents:]
    {ListItemComponent}
    type: 'imageItem.
    {GalleryImages}
    }

    ]

    onTriggered: {}

    It's easy

    var point = dataModel.data (row);

    BUT HOW to ACCESS the GalleryImages instance for the row?

    }

    ...

    I'm sure it's really simple, but have been hitting my head against it for 2 days!

    C

    https://developer.BlackBerry.com/Cascades/reference/bb__cascades__listview.html

    your variable 'point' reference the underlying data in the datamodel - it does not refer to the list Visual element (i.e. ListItemComponent).

    You need to move your manager in the ListItemComponent - and probably change in notecard or anything that supports your component of GalleryImages.

  • Add onTriggered to c ++ created ActionSet

    In the ActionSet documentation, it shows 2 ActionSets for an image

    ImageView {
        imageSource: "john.png"
        contextActions: [
            ActionSet {
                title: "Email"
                subtitle: "From: John Doe"
                ActionItem {title: "Reply"}
                ActionItem {title: "Forward"}
            },
            ActionSet {
                title: "Sender"
                ActionItem {title: "Call"}
                ActionItem {title: "Send SMS"}
            }
        ]
    }
    

    But it does not specify whether or not you can make an active set and disable the other.  Future feature?

    When you create an ActionSet in c ++, it doesn't seem like there is a way to add the function OnTriggered

    ImageView* imageView = ImageView::create("john.png");
    ActionSet* actionSet = ActionSet::create()
               .title("Email")
               .subtitle("From: John Doe")
               .add(ActionItem::create().title("Reply"))
               .add(ActionItem::create().title("Forward"));
    imageView->addActionSet(actionSet);
    

    Is it possible to add "onTriggered"?

    Or, is there a way to determine what ActionItem has been selected?

    It is a future feature and has been for awhile now.

    Simply add your onTriggered to the ActionItem...

    ActionSet::create()
        .title(tr("Label style"))
        .subtitle(tr("Select an action."))
        .add(ActionItem::create()
                .onTriggered(this, SLOT(onMove()))
                .image(QUrl("asset:///images/actions/label_move.png"))
                .title(tr("Move")))
    
  • ListView onTriggered event to push a new page

    Currently, I started to learn and develop applications for bb10. I saw troubled when wants to push a new page when click the item in the listview.

    ListView {
                dataModel: XmlDataModel {
                    source: "model.xml"
                }
    
                listItemComponents: [
                    ListItemComponent {
                        type: "listItem"
                        StandardListItem {
                            title: ListItemData.title
                            description: ListItemData.subtitle
                            status: ListItemData.status
                        }
                    }
                ]
                onTriggered: {
                    var new_page = nextpage.createObject();
                    navigationPane.push(new_page);
                }
    
                attachedObjects: [
                    ComponentDefinition {
                        id: nextpage
                        source: "newqml.qml"
                    }
                ]
            }
    

    The code that I use, I expect to get to the newqml.qml, then click on any point on the listview however is not doing. How can I change the code to obtain the result.

    and if I want it open different page each item in listview how does?

    Thanks in advance.

    Hello

    I'm new on this, but I have a tip that could help: create a new project, select stunts, then on the models page, select ListView.

    This will automatically create a default list that automatically connects your article to an ItemPage.qml of a second!

  • Finished SystemToast SIGNAL not

    No idea why this is happening? Is this a bug?

    void HelpPage::showToastNotification()
    {
        SystemToast *toast = new SystemToast(this);
        toast->setBody("Success.");
        toast->button()->setLabel("Open");
    
        QObject::connect(toast, SIGNAL(finished(SystemUiResult::Type)),
                this,  SLOT(onToastFinished(SystemUiResult::Type)));
    
        toast->show();
    }
    
    void HelpPage::onToastFinished(bb::system::SystemUiResult::Type result)
    {
          showDialog("Test","Success"); //THIS LINE NEVER GETS CALLED
    
          SystemToast *toast = qobject_cast(sender());
          toast->deleteLater();
    }
    

    Hello

    Use namespace in the list of parameters.

    all

    public slots:          void onToastFinished(bb::system::SystemUiResult::Type);
    

    .cpp

    #include "applicationui.hpp"
    
    #include 
    #include 
    
    using namespace bb::cascades;
    using namespace bb::system;
    
    ApplicationUI::ApplicationUI(bb::cascades::Application *app) :
            QObject(app) {
        QmlDocument *qml = QmlDocument::create("asset:///main.qml").parent(this);
        qml->setContextProperty("app", this);
        root = qml->createRootObject();
        app->setScene(root);
    
        SystemToast *toast = new SystemToast(this);
        toast->setBody("Success.");
        toast->button()->setLabel("Open");
    
        QObject::connect(toast, SIGNAL(finished(bb::system::SystemUiResult::Type)), this,
                SLOT(onToastFinished(bb::system::SystemUiResult::Type)));
    
        toast->show();
    }
    
    void ApplicationUI::onToastFinished(bb::system::SystemUiResult::Type result) {
        qDebug() << "Got it";
        SystemToast *toast = qobject_cast(sender());
        toast->deleteLater();
    }
    

  • Deselect a tab in a TabbedPane onTriggered?

    Hello

    I have 2 tabs in a tabbed pane. If the user selects the tab critical, based on conditonA, I want to deselect the critical tab and select the normal tab. When I tried the code below using tabbedObject.activeTab, the tabs Panel selects the normal tab.

    I really appreciate any help on this issue. Thank you!

    TabbedPane {}

    ID: tabbedObject

    ....

    Tab {}
    ID: criticalTab
    Title: qsTr ("Critical")
    onTriggered: {}

    var Declencheurun = true;
    If (Declencheurun == true) {}

    tabbedObject.activeTab = normalTab;
    }
    }
    imageSource: "asset:///images/ic_stop.png."
        
    }

    Tab {}
    ID: normalTab

    Title: qsTr ("NormalTab")
    onTriggered: {}
                            
               
    }
    imageSource: "asset:///images/ic_stop.png."
        
    }

    }

    Solved

    I have to listen to onActiveTabChanged in the TabbedPane and deselect it here.

  • onTrigger go to the last line of the ListView

    Hello

    The above is possible? I have a list of RSS, I would like to know is there a way I can do onTrigger go to the last column in my listView.

    Thank you

    How can I get the number of items in dataModel?

    It depends on dataModel type you use, see the documentation for the corresponding classes.

    For ArrayDataModel and GroupDataModel:

    var n = dataModel.size () / / or dataModel.childCount (0) - number of students in first section

    Row is a table where the first number is the section and the second is stored in the section.

    Something like this should work:

    var dataModelSize = listViewId.dataModel.size(); // or listViewId.dataModel.childCount(0)if (dataModelSize > 0)
    {
      var lastRowNumber = dataModelSize - 1
      listViewId.scrollToItem([0, lastRowNumber], ScrollAnimation.Default);
    }
    

    Replace the listViewId with the id of your ListView.

    If this does not work, please copy - paste your current code and errors that appear in the papers (as appropriate).

  • How to send C++ objects to the body of SystemToast

    Hello

    I try to send my C++ object value to the body of SystemToast through QML property.

    I did the steps to save the QML C++ object via the setContextProperty method. This works because I am able to change the value (which is of type QString) to the text property of the label to a QML.

    When I run the app, the SystemToast opens with empty text.

    Any suggestions?

    Thank you

    This is related to the scope of the listitemcomponent, it doesn't have access to the cppObject because he has a different scope.

    You can generally save or create a feature on the listview which is accessed through the listitemcomponent.

  • SystemToast predefined time

    Hello

    I wonder if anyone knows if it is possible to set the timeout for a systemToast? In the link below, it mentions a "predefined time '... Is it possible to set this period?

    https://developer.BlackBerry.com/Cascades/reference/bb__system__systemtoast.html

    (The toast will be rejected after a predefined time lapses...)

    Thank you

    Jason

    Currently, there is no way to set the amount of a SystemToast.  If this is a feature that you want to see that I suggest in the direction of https://www.blackberry.com/jira and the creation of a asked to feature that I can climb for you.

  • Action on multiple selection ListView onTriggered

    Hi, I have a listview with multiSelectHandler impleted and so can select multiple items.

    I'm having a problem on how to perform the action on these several items though.

    Documentation, http://developer.blackberry.com/cascades/documentation/ui/lists/list_view_selection.html, does not show how to perform the action when several items to the listview are selected.

    Does anyone know how to make measurements on multiple items? i.e. remove it from the list, get the text of each article, changes to the user interface, etc.

    Hello

    Have you seen Battambang sample? I remember well, it can perform operations on several list items:

    https://github.com/BlackBerry/Cascades-samples/tree/master/bucketlist

Maybe you are looking for