Important: Please read the Qt Code of Conduct -

How to read a text in a line edit which is used in a stacked widget?

  • I am working on an application that requires several pages. So i used stacked widget in a mainwindow. There is a sign in page . I want to read and write the text in lineEdit given by the users which will be stored in a text file.
    Can anyone help me with this thanks in advance .
    p.s: I am completely new with qt so if you can give me full description it will be very helpful.

    here is the code.
    Error massage sauys : No member named lineEdit in stackedWidget

    QString Email= ui->stackedWidget-> lineEdit_email->text();
    QString Password = ui->stackedWidget->lineEdit_password->text();

  • Qt Champions 2017

    First you need to understand What is the QStackWidget & how it works.
    There is nice example given in the Qt Assistant. You can refer it.

    Once you understand this
    You can use the following APIs to get the appropriate widget using the following method.

    int index=0;
    QLineEdit edit = qobject_cast<QLineEdit>(widget(index));

    Index is the index of the Widget you have inserted in StackWidget.

    I'm not sure how you have created individual pages.

Log in to reply