i want to take input from a textbox/textarea.
what are the classes needed for it?
and if i want to check the validity of the input(like int/float etc.) are there any inbuilt functions?
i am a newbie in Qt programming.
Printable View
i want to take input from a textbox/textarea.
what are the classes needed for it?
and if i want to check the validity of the input(like int/float etc.) are there any inbuilt functions?
i am a newbie in Qt programming.
can you give an example code.
this is my first project(better to say first code)in Qt.
Take a look at QInputDialog if you want to receive values directly from user. For validating, inputdialog itself has different functions using which you can differentiate between double, int etc.
Let me know if you dont understand any line of the code. I used qdebug(), then you can see when pressing a Qpushbutton the string data is captured and can be seen with Qt Creator (in application output).
-E
Code:
#include <QtGui> { Q_OBJECT public: { connect(captureText,SIGNAL(clicked()),this, SLOT(storeText())); layout->addWidget(textUser); layout->addWidget(captureText); setLayout(layout); } public slots: void storeText() { qDebug() << "Text captured by neutrino: " << str; } private: QLineEdit *textUser; QPushButton *captureText; }; int main(int argc, char *argv[]) { ExampleForNeutrino e; e.show(); return a.exec(); } #include "main.moc"
In my case that code works (i did it and compiled in my pc)
Clean the .pro file and leave only the line "SOURCES += main.cpp", and rebuild. Let me know if it works.
If not, take a look here
-E
my file name was different.
i changed it to main.cpp and it worked.
thanks