Results 1 to 5 of 5

Thread: how to access widgets values?

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Aug 2009
    Location
    coimbatore,India
    Posts
    314
    Thanks
    37
    Thanked 47 Times in 43 Posts
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default how to access widgets values?

    by using folowing coding , i can able to create label,lineedit,pushbuttons.

    how to access lineedit's typed value.. when the user clicks a pushbutton(EX show)?
    i dont know how to get the values of WIDGETS.?

    pls kindly help me

    These are the files im using:

    DynamicControls.h
    Qt Code:
    1. //DynamicControls.h
    2. class DynamicControls : public QDialog
    3. {
    4. Q_OBJECT
    5.  
    6. public:
    7. DynamicControls(QWidget *parent = 0);
    8. QGridLayout *layout;
    9. QLabel *label;
    10. QLineEdit *lineEdit;
    11. QLineEdit *pushbutton;
    12.  
    13. QString tableName;
    14. void createLabel(QString Wstr,QString WTip ,int x,int y);
    15. void createLineEdit(QString Wstr,QString WTip ,int x,int y);
    16. void createLayout();
    17. //void getInfoLineEdit(QString LineEditName);
    18. private slots:
    19. void updateTable();
    20. private:
    21.  
    22. };
    To copy to clipboard, switch view to plain text mode 


    DynamicControls.cpp
    Qt Code:
    1. //DynamicControls.cpp
    2. #include <QtGui>
    3. #include <QSqlQuery>
    4. #include <QVariant>
    5.  
    6. #include "dynamiccontrols.h"
    7.  
    8. DynamicControls::DynamicControls(QWidget *parent)
    9. : QDialog(parent)
    10. {
    11. layout = new QGridLayout;
    12. }
    13.  
    14. void DynamicControls::createLabel(QString Wstr,QString WTip,int x,int y)
    15. {
    16. label=new QLabel(Wstr);
    17. label->setToolTip(WTip);
    18. label->setObjectName(WTip);
    19. layout->addWidget(label,x,y);
    20. }
    21.  
    22. void DynamicControls::createLineEdit(QString Wstr,QString WTip,int x,int y)
    23. {
    24. lineEdit=new QLineEdit(Wstr);
    25. lineEdit->setToolTip(WTip);
    26. lineEdit->setObjectName(WTip);
    27. layout->addWidget(lineEdit,x,y);
    28. }
    29.  
    30. void DynamicControls::createPushButton(QString Wstr,QString WTip,int x,int y)
    31. {
    32. pushbutton= new QPushButton(Wstr);
    33. pushbutton->setToolTip(WTip);
    34. pushbutton->setObjectName(WTip);
    35. layout->addWidget(pushbutton,x,y);
    36. }
    37. void DynamicControls::createLayout()
    38. {
    39. setLayout(layout);
    40. }
    To copy to clipboard, switch view to plain text mode 



    main.cpp
    Qt Code:
    1. #include <QtGui/QApplication>
    2. #include <QVariant>
    3. #include <QLineEdit>
    4. #include "dynamiccontrols.h"
    5. #include "Connection.h"
    6.  
    7. int main(int argc, char *argv[])
    8. {
    9. QApplication a(argc, argv);
    10. DynamicControls *w = new DynamicControls;
    11. w->createLabel("Id","IDLabel",0,0);
    12. w->createLineEdit("","IDLineEdit",1,);
    13. w->createLabel("Name","NameLabel",0,0);
    14. w->createLineEdit("","NameLineEdit",1,);
    15. w->createPushButton("Show","ShowButton",2,0);
    16. w->createLayout();
    17. w->show();
    18. return a.exec();
    19. }
    To copy to clipboard, switch view to plain text mode 

    in the above program, i want to get the values of lineedits namelinedit,idlineedit when the user click show button

    Thnks

    Thnks
    Bala
    Last edited by BalaQT; 21st August 2009 at 17:05.

Similar Threads

  1. Mac OS X Top-Level Transparent Widgets
    By tinsuke in forum Qt Programming
    Replies: 0
    Last Post: 17th October 2008, 16:01
  2. Upper limit on number of widgets?
    By jdiewald in forum Qt Programming
    Replies: 1
    Last Post: 29th September 2008, 23:00
  3. Access to widgets from a Dialog to another one
    By jean in forum Qt Programming
    Replies: 7
    Last Post: 7th August 2008, 09:42
  4. Replies: 2
    Last Post: 16th May 2008, 14:39
  5. Access widgets
    By Gayathri in forum Newbie
    Replies: 2
    Last Post: 17th November 2006, 14:37

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.