• May 22, 2024, 01:36:11 pm

Author Topic: Usage of CommonDialogs QML  (Read 1167 times)

0 Members and 1 Guest are viewing this topic.

Offline Allstar12345

  • Allstar Software Founder
  • Administrator
  • Forum Genius
  • ******
  • Posts: 5,235
  • Reputation: 812
    • Allstar Software
  • Current Phone: : OnePlus 8 Pro, Xperia 10, Nexus 6p, Jolla Phone, Nokia N8, Nokia 808 PureView, BlackBerry Z30
Usage of CommonDialogs QML
« on: June 01, 2013, 03:29:44 am »
The CommonDialog is a handy part of the Symbian Qt Quick Set, you can use it for pretty much anything within reason.

Here is a basic example of one with more than one button, this closes the app, and the second button just writes on the Console.

The Title is defined like this:

Code: [Select]
titleText: "Exit"
Private Close Icon (the little close icon in the top corner)

Code: [Select]
privateCloseIcon: true

The Buttons text:

Code: [Select]
buttonTexts: ["Yes", qsTr("Log on console")]

The Dialogs content, in this case some simple text:

Code: [Select]
content: Label { anchors.centerIn: parent; text: "Are you sure you want to leave?";}


Finally the commands for the buttons themselves, the first button as
Code: [Select]
if (index === 0) Qt.quit();The second button as
Code: [Select]
  else if (index === 1) Console.log ("Button Two Pressed")
For a third and more you would carry on changing the
Code: [Select]
(index === 1) to
Code: [Select]
(index === 2) and carry on changing the number up for each one.

 onButtonClicked: {
                    if (index === 0) Qt.quit();
                           else if (index === 1) Console.log ("Button Two Pressed")

            }
Code: [Select]
   
     CommonDialog {
                id: closeDialog
                titleText: "Exit"
                privateCloseIcon: true
                buttonTexts: ["Yes", qsTr("Log on console")]
                content: Label { anchors.centerIn: parent; text: "Are you sure you want to leave?";}
                onButtonClicked: {
                    if (index === 0) Qt.quit();
                           else if (index === 1) Console.log ("Button Two Pressed")

            }
    }

Offline huellif

  • Developer
  • Christmas Santa
  • ****
  • Posts: 402
  • Reputation: 212
Re: Usage of CommonDialogs QML
« Reply #1 on: June 01, 2013, 03:49:44 am »
really usefull topic mate :)
« Last Edit: August 06, 2013, 12:08:46 am by huellif »

Offline Allstar12345

  • Allstar Software Founder
  • Administrator
  • Forum Genius
  • ******
  • Posts: 5,235
  • Reputation: 812
    • Allstar Software
  • Current Phone: : OnePlus 8 Pro, Xperia 10, Nexus 6p, Jolla Phone, Nokia N8, Nokia 808 PureView, BlackBerry Z30
Re: Usage of CommonDialogs QML
« Reply #2 on: June 01, 2013, 03:52:53 am »
really usefull topc mate :)
Cheers :D
It can literally hold loads, My SD App holds a Flickable with a WebView in a CommonDialog :P