Results 1 to 5 of 5

Thread: Qt 4.8: How to use setText() of QLineEdit.

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Oct 2011
    Posts
    19
    Thanks
    2
    Qt products
    Qt3
    Platforms
    Unix/X11

    Default Qt 4.8: How to use setText() of QLineEdit.

    I recently migrated from Qt 3 to Qt4.8 ( I know huge jump.) Was restricted to work on qt3 before. Anyway, I was trying out this particular program, where I am creating two QLineEdit boxes and trying to to get the text of l1 to l2 (l1 and l2 bring the names of the QLineEdit respectively.) For this I was created the signal and slots but when I compile I get this error "Undefined reference to setText()". I was using the signal textChanged() of l1 and slot of l2 - setText(). Think anyone can help me on this?



    I think I am just missing something. Got gambled with all the qt3 and 4 concepts. Please pardon my poor code and concepts. Patience would be appriciated. Thanks.
    try1.cpp
    Qt Code:
    1. #include<QtGui>
    2. #include<QDialog>
    3. #include<QLineEdit>
    4. #include<QLabel>
    5. #include<QPushButton>
    6. #include "try1.h"
    7. #include "ui_try1.h"
    8.  
    9. try1::try1(QWidget *parent):QDialog(parent), ui(new Ui::Dialog)
    10. {
    11. //ui->setupUi(this);
    12. connect(ui->l1,SIGNAL(textChanged(const QString &)),ui->l2,SLOT(setText(const QString &)) );
    13. //connect(ui->Quit,SIGNAL(clicked()),this,SLOT(close()));
    14. }
    To copy to clipboard, switch view to plain text mode 
    try1.h
    Qt Code:
    1. #ifndef TRY1_H
    2. #define TRY1_H
    3. #include "ui_try1.h"
    4. #include<QDialog>
    5. #include<QLineEdit>
    6. #include<QLabel>
    7. #include<QPushButton>
    8. //class ;
    9. //class QLineEdit;
    10. //class QPushButton;
    11.  
    12. namespace Ui
    13. {
    14. class Dialog;
    15. }
    16.  
    17.  
    18. class try1:public QDialog
    19. {
    20. Q_OBJECT
    21. public:
    22. try1(QWidget *parent=0);
    23. private:
    24. Ui::Dialog *ui;
    25. signals:
    26. void textChanged(const QString &text);
    27. // void clicked();
    28. private slots:
    29. void setText(const QString &text);
    30. //void close();
    31. private:
    32. QLabel *l1;
    33. QLabel *l2;
    34. QLineEdit *t1;
    35. QLineEdit *t2;
    36. QPushButton *Quit;
    37. };
    38.  
    39. #endif
    To copy to clipboard, switch view to plain text mode 

    main.cpp (init)
    Qt Code:
    1. #include<QtGui>
    2. #include<QApplication>
    3. #include<QDialog>
    4. #include "try1.h"
    5.  
    6. int main(int argc,char *argv[])
    7. {
    8. QApplication app(argc,argv);
    9. try1 d;
    10. d.show();
    11. return app.exec();
    12. }
    To copy to clipboard, switch view to plain text mode 

    Also attaching the zip file of the project. And again really sorry for messy code.
    Attached Files Attached Files

Similar Threads

  1. Replies: 6
    Last Post: 4th December 2020, 23:11
  2. Replies: 1
    Last Post: 12th October 2010, 22:20
  3. settext
    By seltra in forum Newbie
    Replies: 4
    Last Post: 3rd October 2010, 14:52
  4. Problem with QLineEdit and setText
    By Elmo23x in forum Qt Programming
    Replies: 8
    Last Post: 12th April 2007, 12:35
  5. Replies: 1
    Last Post: 26th November 2006, 09:32

Tags for this Thread

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.