Scanf with TextEdit



  • Hi,

    I have a problem with qt creator. I study on "textEdit". I want to do "scanf" with textedit. Is it possible?



  • Not sure i understand completely your question,
    Something like this would help :

    @
    class CMyMainWindow
    {
    public:
    CMyMainWindow()
    init();

    private slots:
    void nameChanged();

    private:
    QTextEdit m_textEditName;
    QString m_theName;
    }

    CMyMainWindow::int()
    {
    ...
    connect (m_textEditName, SIGNAL(textChanged()), this, SLOT(nameChanged()));
    }

    void CMyMainWindow::nameChanged()
    {
    m_theName = m_textEditName->toPlainText();
    }
    @

    The slot function "nameChanged()" will be called every time the textEdit is modified, updating the filed member "m_theName" (Thank to the "connect")

    (Perhaps a QLineEdit would be more suitable, no ?)



  • In Qt we don't use the function "scanf", you can give what is there in a variable or you can work just wich is in the line edit or text edit.

    in line edit be this:

    @ui->lineEdit->text();@


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.