← Back to team overview

ubuntu-phone team mailing list archive

Re: Ubuntu QML Dialogs

 

Hi Николай,

Your reference to dialog does not exist because it is inside a Component,
it is not an item (it is like a class definition, not an instance). I
propose that you update the properties that you want to update from inside
the Button's onClicked in the Dialog. For example, if you add this to your
main Item:

id: root
property string someText

then, in one of the Button.onClicked functions you can add:
root.someText = "Hello world";


To answer your other questions about radio buttons and checkboxes:
- There are currently  no radio buttons in the SDK. There is a
ListItem.ValueSelector which may fit your needs, or otherwise a Column with
multiple ListItems  where selecting one deselects the others may be used.
- Dialog only supports buttons, and this is done on purpose because a
Dialog is there to ask the user to make a choice by pressing one of the
buttons, see http://design.ubuntu.com/apps/building-blocks/dialog
For different needs, there are Popovers and Sheets. See
http://developer.ubuntu.com/api/ubuntu-12.10/qml/mobile/overview-ubuntu-sdk.html#popovers-sheets-and-dialogs
 and http://design.ubuntu.com/apps/building-blocks/popover

Greets,
Tim.


On Thu, Apr 11, 2013 at 3:16 AM, Николай Шатохин <n.shatokhin@xxxxxxxxx>wrote:

> Hello,
>
> I used Dialog by this way:
>
> I created ConfirmationDialog.qml:
>
> import QtQuick 2.0
>
> import Ubuntu.Components 0.1
>
> import Ubuntu.Components.Popups 0.1
>
>
> Item {
>
>     signal confirmed;
>
>     signal canceled;
>
>
>     signal show(variant caller);
>
>
>     Component {
>
>          id: dialogComponent
>
>
>          Dialog {
>
>              id: dialog
>
>              title: "Exit Game"
>
>              text: "Are you sure that you want to exit?"
>
>
>              Button {
>
>                  text: "cancel"
>
>                  onClicked:
>
>                  {
>
>                      canceled();
>
>                      PopupUtils.close(dialog);
>
>                  }
>
>              }
>
>              Button {
>
>                  text: "confirm"
>
>                  color: "orange"
>
>                  onClicked:
>
>                  {
>
>                      confirmed();
>
>                      PopupUtils.close(dialog);
>
>                  }
>
>              }
>
>          }
>
>     }
>
>
>     onShow:
>
>     {
>
>         PopupUtils.open(dialogComponent, caller)
>
>     }
>
> }
>
>
> And in MainMenu.qml I create item:
>
>
>     ConfirmationDialog
>
>     {
>
>         id: confirmExitDialog
>
>     }
>
>
> And call this dialog in button:
>
>
>         Button {
>
>             id: quitBtn
>
>
>             onClicked: {
>
>                 confirmExitDialog.confirmed.connect(quit);
>
>                 confirmExitDialog.show(quitBtn);
>
>             }
>
>         }
>
>
> Is this a good dialog usage? How to use aliases for changing title and text in item creation?
>
>
> If I write:
>
>
> property alias title: dialog.title
>
>
> in Item's body in ConfirmationDialog.qml, I see error:
>
>
> qrc:/ConfirmationDialog.qml:8:23: Invalid alias reference. Unable to find id "dialog"
>
>
> How to resolve this?
>
>
> Best regards,
>
> Nick
>
>
>
> 2013/4/11 Николай Шатохин <n.shatokhin@xxxxxxxxx>
>
>> I don't need help with Dialog. I need help with showing them and getting
>> value from them. I created ConfirmationDialog.qml that has Component with
>> Dialog. How can I show it in MainMenu.qml and get selected value from them?
>>
>>
>> 2013/4/11 Robert Bruce Park <robert.park@xxxxxxxxxxxxx>
>>
>>> On Thu, Apr 11, 2013 at 12:00:19AM +0300, Николай Шатохин wrote:
>>> > How to use this dialog?
>>> http://developer.ubuntu.com/api/ubuntu-12.10/qml/mobile
>>> > /qml-ubuntu-components-popups0-dialog.html
>>>
>>> The first screenful of this page gives a code listing that shows how
>>> to define the dialogue and how to have it pop up when a button is
>>> clicked. What part of that do you need help with?
>>>
>>> > For example, I have main menu with few buttons and I want to ask user
>>> > confirmation when he's clicking exit button.
>>>
>>> That sounds to me like you can copy&paste exactly what is in the
>>> example and just name your button 'Quit'.
>>>
>>> > How to create dialog with radio or check buttons?
>>>
>>> That I don't know.
>>>
>>
>>
>
> --
> Mailing list: https://launchpad.net/~ubuntu-phone
> Post to     : ubuntu-phone@xxxxxxxxxxxxxxxxxxx
> Unsubscribe : https://launchpad.net/~ubuntu-phone
> More help   : https://help.launchpad.net/ListHelp
>
>

References