Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to use field of the qwizard?
QtWS25 Last Chance

How to use field of the qwizard?

Scheduled Pinned Locked Moved General and Desktop
4 Posts 3 Posters 1.6k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    bear234
    wrote on last edited by
    #1

    what I want is:
    create a wizard, when I click "finish", I can get some data of the wizardpages.

    for example, a wizard with 2 pages:
    1 page contains a ListWidget
    2 page is just for finishing this wizard.

    what i want is: when I click "finish", I can get a list which contains all of the items in that ListWidget.

    for this goal, I do like this:

    I create a WizardPage2 who inherits the class QWizardPage.
    in the ui of this class, there is a QListWidget.
    i code like this in his constructor:
    @
    registerField("liste", ui->listWidget);
    @

    and I create a AideWizard who inherits the class QWizard, and I overwrite his fonction: accept()
    @
    void AideWizard::accept()
    {
    //I dont know how to recover that QListWidget with field("name");
    QWizard::accept();
    }
    @

    I ve tried to find some examples but all of them are about recovering some QString. but for me, I want to recover a QListWidget.

    can u help me???

    1 Reply Last reply
    0
    • JeroentjehomeJ Offline
      JeroentjehomeJ Offline
      Jeroentjehome
      wrote on last edited by
      #2

      Hi,
      You should think more abstract and think about who needs the data, not who will supply it. Somebody will start the Wizard, so that piece of code will own the wizard class construction. When the wizard returns 'accepted' like any other dialog the class is still there. Use a 'getter' function in your wizard class to supply the creator to receive the data. The data may be anything that can be hold in a QVariant ;-)
      So more like this:
      @
      // This is the class that creates the wizard dialog
      MyWizard * AskStuff_p = new MyWizard(this);
      if (AskStuff_p.exec() == QDialog::accept)
      {
      QList MyList = AskStuff_p.GetList();
      }

      // And in your Wizard dialog somewhere:
      QList MyWizard::GetList(void)
      {
      QList NewList;
      NewList.append(ui->listItem); // Fill the list from GUI elements

      return NewList;
      }
      @
      Could check some code in an old project, but this should do it.

      Greetz, Jeroen

      1 Reply Last reply
      0
      • C Offline
        C Offline
        ChrisW67
        wrote on last edited by
        #3

        Alternative:

        You could subclass QListWidget for use in your wizard. Provide the subclass with a Q_PROPERTY that returns whatever you want from the list as a QStringList (or some other type that can go in a QVariant) and provide a changed signal. Then register a field:
        @
        registerField("liste", ui->subclassedListWidget, "myDataProperty", "myDataPropertyChanged");
        @

        After the dialog is accepted the value can be retrieved using QWizard::field()

        1 Reply Last reply
        0
        • B Offline
          B Offline
          bear234
          wrote on last edited by
          #4

          ah, this is exactly what i need.

          thx a lot

          [quote author="Jeroentje@home" date="1391021915"]Hi,
          You should think more abstract and think about who needs the data, not who will supply it. Somebody will start the Wizard, so that piece of code will own the wizard class construction. When the wizard returns 'accepted' like any other dialog the class is still there. Use a 'getter' function in your wizard class to supply the creator to receive the data. The data may be anything that can be hold in a QVariant ;-)
          So more like this:
          @
          // This is the class that creates the wizard dialog
          MyWizard * AskStuff_p = new MyWizard(this);
          if (AskStuff_p.exec() == QDialog::accept)
          {
          QList MyList = AskStuff_p.GetList();
          }

          // And in your Wizard dialog somewhere:
          QList MyWizard::GetList(void)
          {
          QList NewList;
          NewList.append(ui->listItem); // Fill the list from GUI elements

          return NewList;
          }
          @
          Could check some code in an old project, but this should do it.[/quote]

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved