Results 1 to 8 of 8

Thread: taking input from the input box

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #5
    Join Date
    Jun 2011
    Posts
    26
    Thanks
    3
    Thanked 3 Times in 3 Posts

    Default Re: taking input from the input box

    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:
    1. #include <QtGui>
    2.  
    3. class ExampleForNeutrino: public QWidget
    4. {
    5. Q_OBJECT
    6. public:
    7.  
    8. ExampleForNeutrino(QWidget *p = 0): QWidget(p)
    9. {
    10. textUser = new QLineEdit(tr("Insert text"));
    11. captureText = new QPushButton(tr("CaptureText"));
    12. connect(captureText,SIGNAL(clicked()),this, SLOT(storeText()));
    13.  
    14. QVBoxLayout *layout = new QVBoxLayout();
    15. layout->addWidget(textUser);
    16. layout->addWidget(captureText);
    17. setLayout(layout);
    18.  
    19. }
    20.  
    21. public slots:
    22. void storeText()
    23. {
    24. QByteArray str = textUser->text().toAscii();
    25. qDebug() << "Text captured by neutrino: " << str;
    26. }
    27.  
    28. private:
    29. QLineEdit *textUser;
    30. QPushButton *captureText;
    31. };
    32.  
    33. int main(int argc, char *argv[])
    34. {
    35.  
    36. QApplication a(argc, argv);
    37.  
    38. ExampleForNeutrino e;
    39. e.show();
    40. return a.exec();
    41. }
    42. #include "main.moc"
    To copy to clipboard, switch view to plain text mode 

  2. The following user says thank you to Ethan for this useful post:

    neutrino (30th September 2011)

Similar Threads

  1. input raw data
    By Marina K. in forum Qt Programming
    Replies: 2
    Last Post: 17th May 2011, 17:28
  2. Raw Input in QT4
    By been_1990 in forum Qt Programming
    Replies: 5
    Last Post: 13th September 2010, 18:54
  3. input audio
    By addu in forum Qt Programming
    Replies: 9
    Last Post: 10th September 2009, 11:12
  4. QIntValidator input
    By chaos_theory in forum Qt Programming
    Replies: 4
    Last Post: 19th August 2007, 10:28
  5. regarding input widget
    By jagadish in forum Qt Tools
    Replies: 1
    Last Post: 28th June 2007, 12:07

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.