BalaQT
21st August 2009, 17:00
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
//DynamicControls.h
class DynamicControls : public QDialog
{
Q_OBJECT
public:
DynamicControls(QWidget *parent = 0);
QGridLayout *layout;
QLabel *label;
QLineEdit *lineEdit;
QLineEdit *pushbutton;
QString tableName;
void createLabel(QString Wstr,QString WTip ,int x,int y);
void createLineEdit(QString Wstr,QString WTip ,int x,int y);
void createLayout();
//void getInfoLineEdit(QString LineEditName);
private slots:
void updateTable();
private:
};
DynamicControls.cpp
//DynamicControls.cpp
#include <QtGui>
#include <QSqlQuery>
#include <QVariant>
#include "dynamiccontrols.h"
DynamicControls::DynamicControls(QWidget *parent)
: QDialog(parent)
{
layout = new QGridLayout;
}
void DynamicControls::createLabel(QString Wstr,QString WTip,int x,int y)
{
label=new QLabel(Wstr);
label->setToolTip(WTip);
label->setObjectName(WTip);
layout->addWidget(label,x,y);
}
void DynamicControls::createLineEdit(QString Wstr,QString WTip,int x,int y)
{
lineEdit=new QLineEdit(Wstr);
lineEdit->setToolTip(WTip);
lineEdit->setObjectName(WTip);
layout->addWidget(lineEdit,x,y);
}
void DynamicControls::createPushButton(QString Wstr,QString WTip,int x,int y)
{
pushbutton= new QPushButton(Wstr);
pushbutton->setToolTip(WTip);
pushbutton->setObjectName(WTip);
layout->addWidget(pushbutton,x,y);
}
void DynamicControls::createLayout()
{
setLayout(layout);
}
main.cpp
#include <QtGui/QApplication>
#include <QVariant>
#include <QLineEdit>
#include "dynamiccontrols.h"
#include "Connection.h"
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
DynamicControls *w = new DynamicControls;
w->createLabel("Id","IDLabel",0,0);
w->createLineEdit("","IDLineEdit",1,);
w->createLabel("Name","NameLabel",0,0);
w->createLineEdit("","NameLineEdit",1,);
w->createPushButton("Show","ShowButton",2,0);
w->createLayout();
w->show();
return a.exec();
}
in the above program, i want to get the values of lineedits namelinedit,idlineedit when the user click show button
Thnks
Thnks
Bala
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
//DynamicControls.h
class DynamicControls : public QDialog
{
Q_OBJECT
public:
DynamicControls(QWidget *parent = 0);
QGridLayout *layout;
QLabel *label;
QLineEdit *lineEdit;
QLineEdit *pushbutton;
QString tableName;
void createLabel(QString Wstr,QString WTip ,int x,int y);
void createLineEdit(QString Wstr,QString WTip ,int x,int y);
void createLayout();
//void getInfoLineEdit(QString LineEditName);
private slots:
void updateTable();
private:
};
DynamicControls.cpp
//DynamicControls.cpp
#include <QtGui>
#include <QSqlQuery>
#include <QVariant>
#include "dynamiccontrols.h"
DynamicControls::DynamicControls(QWidget *parent)
: QDialog(parent)
{
layout = new QGridLayout;
}
void DynamicControls::createLabel(QString Wstr,QString WTip,int x,int y)
{
label=new QLabel(Wstr);
label->setToolTip(WTip);
label->setObjectName(WTip);
layout->addWidget(label,x,y);
}
void DynamicControls::createLineEdit(QString Wstr,QString WTip,int x,int y)
{
lineEdit=new QLineEdit(Wstr);
lineEdit->setToolTip(WTip);
lineEdit->setObjectName(WTip);
layout->addWidget(lineEdit,x,y);
}
void DynamicControls::createPushButton(QString Wstr,QString WTip,int x,int y)
{
pushbutton= new QPushButton(Wstr);
pushbutton->setToolTip(WTip);
pushbutton->setObjectName(WTip);
layout->addWidget(pushbutton,x,y);
}
void DynamicControls::createLayout()
{
setLayout(layout);
}
main.cpp
#include <QtGui/QApplication>
#include <QVariant>
#include <QLineEdit>
#include "dynamiccontrols.h"
#include "Connection.h"
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
DynamicControls *w = new DynamicControls;
w->createLabel("Id","IDLabel",0,0);
w->createLineEdit("","IDLineEdit",1,);
w->createLabel("Name","NameLabel",0,0);
w->createLineEdit("","NameLineEdit",1,);
w->createPushButton("Show","ShowButton",2,0);
w->createLayout();
w->show();
return a.exec();
}
in the above program, i want to get the values of lineedits namelinedit,idlineedit when the user click show button
Thnks
Thnks
Bala