Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Looking at the Dialog component example in the Ubuntu SDK documentation, it looks as if dialogs are intended to be defined as static components with fixed title and text. Or at least I cannot figure out how to change it before showing the dialog.

I've also been hinted at the show() method of the PopupBase class on which Dialog is based, but I've not worked out how to use them for my purposes.

I've got a signal handler in my code where I'd like to open a dialog and dynamically set the title and text.

onSomethingHappened: {
   /* Open a dialog and set the title and text properties */

How can I do that?

share|improve this question
I have seen that you have found a different, better solution. Since I have voted to close another question as a duplicate of this one, you might want to add your solution as well. – xubuntix Jun 10 '13 at 15:31
Done, thanks! Sorry, I found out shortly after having asked the question and was intending to post the answer, I just didn't have an Internet connection at the time :) – David Planella Jun 10 '13 at 18:39

This is not an answer to your question since the dialog text is not directly changed, but it might be an answer to your problem, since the dialog text changes itself dynamically :-)

Assuming that you have some item that triggeres the onSomethingHappened, you could connect properties of the dialog to properties of the item.


Item {
  Component {
     id: dialog
     Dialog {
        id: dialogue
        title: someID.dialogTitle
        text: someID.dialogText
        Button {
            text: "cancel"
            onClicked: PopupUtils.close(dialogue)

SomeItem {
  id: someID
  property string dialogTitle
  property string dialogText
  onSomethingHappened: {
     dialogTitle = "Hello David"
     dialogText = "Whats up?"
share|improve this answer
In essence, it's what I was asking for. However, I've found an alternative way that does not depend on the Dialog component to know in advance the id of the caller, so I've posted it as another answer. Thanks! – David Planella Jun 10 '13 at 18:48
up vote 4 down vote accepted

I've found I can do this with the following snippet in my code (root is the caller id for the open() method, but can be ignored for this example). Essentially, populating the params argument in the function:"QrCodeDialog.qml"), root, {
                    title:"This is the title"),
                    text:"This is the text")

And then the QrCodeDialog.qml file contains:

import QtQuick 2.0
import Ubuntu.Components 0.1
import Ubuntu.Components.Popups 0.1

Dialog {
    id: qrcodedialog
    title: ""
    text: ""

    Button {
        onClicked: PopupUtils.close(qrcodedialog)
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.