cannot find main.moc
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
Qt 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"#include <QtGui> class ExampleForNeutrino: public QWidget { Q_OBJECT public: ExampleForNeutrino(QWidget *p = 0): QWidget(p) { textUser = new QLineEdit(tr("Insert text")); captureText = new QPushButton(tr("CaptureText")); connect(captureText,SIGNAL(clicked()),this, SLOT(storeText())); QVBoxLayout *layout = new QVBoxLayout(); layout->addWidget(textUser); layout->addWidget(captureText); setLayout(layout); } public slots: void storeText() { QByteArray str = textUser->text().toAscii(); qDebug() << "Text captured by neutrino: " << str; } private: QLineEdit *textUser; QPushButton *captureText; }; int main(int argc, char *argv[]) { QApplication a(argc, argv); ExampleForNeutrino e; e.show(); return a.exec(); } #include "main.moc"To copy to clipboard, switch view to plain text mode





Reply With Quote
Bookmarks