Nominate our 2022 Qt Champions!

QWidget with QWidgetPages and how to get QListWidget information from another QWidgetPage

  • Hi cute people.

    I need the information containing in a QListWidget from QWidgetPage1 in the next QWidgetPage (2).

    I register the Field as a mandatory Field.

    @registerField("filesListWidget*", m_pWizardPage->lvFiles);@

    But i do not want to know the current row number, i want every entry in the list.

    How can i do that?

  • you need to access your model item instead of your list object.

  • Hi mohsen,

    thanks for your reply, but unfortunately i do not understand what you mean with "model item".

    In the list are several QStrings with absolute directories to different files.
    I just want to read this List of Strings in the next WizardPage.


  • It is a bit strange to use fields for something like this. What is the actual information you wish to convey between the pages?

    If you really need access to the list widget itself, I would just give the wizard page that contains the QListWidget a getter function for the pointer to the widget, and give the page where I'd need access a setter function. Then, when you create the pages, you make sure that you call the setter with the value of the getter you just defined.

  • Hi Andre.
    Thank you for your post.

    Actualy I just need the QStrings in a QList<QString> (or QStringList) in the next QWidgetPage.

    I am really new with Qt and I do not know how do get Informations like these from Page1 to Page2.

    Maybe you can give me an example how to do that?

  • OK, I am now guessing you are somehow building up this list of QStrings in your QListWidget at Page1, and you want the resulting list in Page2. In that case, a field does make sense. However, I would make it a field that represents the actual QStringList, instead of the QListWidget. Your other page does not need to know that you have a QListWidget or something else there, right?

    In your case, I would give my Page1 a custom property like this:
    //header for Page1:
    class Page1: public QWizardPage {
    Q_PROPERTY (QStringList theStringList READ theStringList WRITE setTheStringList NOTIFY theStringListChanged)

    public slots:
    void setTheStringList (QStringList list);

       QStringList theStringList() const;

    //and all your other stuff already there, of course

    You can implement the setter to update the contents of the QListWidget, and the getter to build up a QStringList out of the contents of the QListWidget on the fly. Of course, you should emit the signal whenever the contents change.

    Then, you can easily define a field like this:
    registerField("theStringList*", this, "theStringList");

    That is: you register a field with the page on the page itself.

  • Thank you for your big help.

    In effect I solved the task on an other way.
    I just delegate an own Signal from Page1 through the Wizard to an own Slot of Page2.

    @connect(this->page(page1), SIGNAL(changed(QList<QString>)), this->page(page2), SLOT(magic(QList<QString>)));@

    But your solution helped me a lot.

    Thank you verry much.

Log in to reply