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
Developer
smiley
Posts: 1,360
Registered: ‎07-14-2008
My Carrier: Fido
Accepted Solution

How to remove Cancel button in SystemDialog in QML?

I have this in QML to display the system dialog.

 

          SystemDialog {
             id: myQmlDialog
             title: "Title"
             body: "hello there"
          }

and I call it with myQmlDialog.show()

everything works except I have both OK and Cancel buttons.  It tried adding

 

myQmlDialog.cancelButton.setLabel(null) before calling show() and it doesn't work.

 

In C++ I have no problem.  what is the magic trick?

 

 

 

 

Please use plain text.
BlackBerry Development Advisor
erahnenfuehrer
Posts: 74
Registered: ‎05-25-2012
My Carrier: Bell

Re: How to remove Cancel button in SystemDialog in QML?

Try cancelButton.label: undefined

Please use plain text.
Developer
smiley
Posts: 1,360
Registered: ‎07-14-2008
My Carrier: Fido

Re: How to remove Cancel button in SystemDialog in QML?

Nada.  It wont even run.  Just crashes.

 

          SystemDialog {
             id: myQmlDialog
             title: "About"
             cancelButton.label: undefined
             body: "body text"
          }

Please use plain text.
BlackBerry Development Advisor
erahnenfuehrer
Posts: 74
Registered: ‎05-25-2012
My Carrier: Bell

Re: How to remove Cancel button in SystemDialog in QML?

This worked for me:

 

// Default empty project template
import bb.cascades 1.0
import bb.system 1.0

// creates one page with one button and a SystemDialog

Page {
    Container {
        layout: DockLayout {
        }
        Button {
            text: "Push"
            
            attachedObjects: [
                SystemDialog {
                    id: myQmlDialog
                    title: "My Title"
                    body: "Message Body"
                    cancelButton.label: undefined
                }
            ]
            onClicked: {
                myQmlDialog.show()
            }
        } // button
    }
}

 In your .cpp file make sure to add:

 

#include <bb/system/SystemDialog>

 And in main():

 

qmlRegisterType<bb::system::SystemDialog>("bb.system", 1, 0, "SystemDialog");

 Also in your .pro file add:

LIBS += -lbbsystem

 

Please use plain text.
Developer
smiley
Posts: 1,360
Registered: ‎07-14-2008
My Carrier: Fido

Re: How to remove Cancel button in SystemDialog in QML?

Thank You.  Now works.  The problem was that the example code I got it was referencing

 

import my.systemDialogs

 

what is the different vs bb.system ??

 

 

Please use plain text.
Regular Contributor
ametller
Posts: 54
Registered: ‎07-15-2010

Re: How to remove Cancel button in SystemDialog in QML?

[ Edited ]

If you included 'import my.systemDialogs' in your QML, it means that you had the following line on the constructor of your application:

 

qmlRegisterType<SystemDialog>("my.systemdialogs", 1, 0, "SystemDialog");

so you only have the SystemDialog class available in Cascades. In order to edit the text of the buttons you also need the SystemUiButton class available in Cascades, so you should include the following line:

 

qmlRegisterType<SystemUiButton>("my.systemdialogs", 1, 0, "SystemUiButton");

In the example above from erahnenfuehrer, it worked because he included 'import bb.system 1.0' which as far as I know includes everything related to system dialogs.

 

Cheers,

Please use plain text.
Developer
javayoung
Posts: 313
Registered: ‎05-31-2010
My Carrier: All

Re: How to remove Cancel button in SystemDialog in QML?

I also tried this solution. The cancel button can be hidden though, the OK button is changed into so big. Is there a way to let OK button keep the original size? Thank you




p(^_^)q
Good good study, day day up
Please use plain text.
New Contributor
Matt_Jia
Posts: 7
Registered: ‎01-23-2013
My Carrier: Developer

Re: How to remove Cancel button in SystemDialog in QML?

I 'm as confused as you...
No claim to God...
Please use plain text.
Developer
javayoung
Posts: 313
Registered: ‎05-31-2010
My Carrier: All

Re: How to remove Cancel button in SystemDialog in QML?

Finally, I customized a dialog and everything is ok.




p(^_^)q
Good good study, day day up
Please use plain text.
Developer
annadanesh
Posts: 82
Registered: ‎01-11-2013
My Carrier: rim

Re: How to remove Cancel button in SystemDialog in QML?

hi,

 

place code howu customizied dialog buuton

 

Please use plain text.