[Solved] Closing a dialog with a timer.
-
for solving my problem i wanted that all the "Question dialogs" be ,ade child of either timeout dialog or the mydialog2. so that whenever they exit, it is possible to close all the open dialogs.
but i dont know how to make one dialog child/parent of other. please help me o this.
-
While creating the Widget, if you pass in the parent widget as argument, it would be the parent. Is that what you are asking for?
@
timeout t;
MyDialog3 dlg3(&t); // dlg3's parent would be t
@You can use "setParent()":http://qt-project.org/doc/qt-4.8/qwidget.html#setParent to set the parent of widget independently, would suggest to go through the manual for Note & Warning.
Is this what you asked for?
-
thanks brother. thanks a lot. my problem is solved................
please tell me the following things:- how to pass value from a lineedit in gui to the backend database for storage
- how to start a new thread in the community
- how to use setParent() function
-
bq. 1) how to pass value from a lineedit in gui to the backend database for storage
lineedit will have a method text() to return whatever entered in lineedit - use this to send to backend database
bq. 2) how to start a new thread in the community
Under Forums -> Qt Development -> General and Desktop -> "Start new discussion":http://qt-project.org/forums/viewforum/10/
bq. 3) how to use setParent() function
Warning: It is very unlikely that you will ever need this function - If you can set the parent while creation, that will be okay.
-
thank a lot for the suggestion. but i have already tried this out. i give mu coding for the form below:
@
#include "mydialog.h"
#include "ui_mydialog.h"
#include <QtCore>
#include <QtGui>
#include <QtSql>
#include"user_data.h"
#include "mydialog30.h"MyDialog::MyDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::MyDialog)
{
ui->setupUi(this);
}MyDialog::~MyDialog()
{
db.close();
delete ui;
}void MyDialog::on_pushButton_5_clicked()
{
if((ui->lineEdit_13->isModified())&& (ui->lineEdit_14->isModified())&&(ui->lineEdit_15->isModified())&&(ui->lineEdit_16->isModified())&&(ui->lineEdit_17->isModified())&& (ui->lineEdit_18->isModified()))
{
QSqlDatabase db= QSqlDatabase::addDatabase("QSQLITE");
db.setDatabaseName("prject3");
db.open();
QSqlQuery q;
q.exec("create table tab1(name char(10),branch char(5),dob char(6),contact number(10),email_id char(10),address char(10));");
QString name= ui->lineEdit_14->text();
QString branch= ui->lineEdit_13->text();
QString date= ui->lineEdit_15->text();
QString cnct =ui->lineEdit_16->text();
QString email= ui->lineEdit_17->text();
QString addrss= ui->lineEdit_18->text();
q.exec("insert into tab1 values('ui->lineEdit_14->text()','ui->lineEdit_13->text()','ui->lineEdit_15->text()','ui->lineEdit_16->text()','ui->lineEdit_17->text()','ui->lineEdit_18->text()');");
user_data d;
d.exec();
}
else
{
MyDialog30 m;
m.exec();
}
}
@
here the problem is that the input is getting accepted perfectly well on using text() function of line edit. but when i am passing it into the database & displaying the output, the output is not being displayed. i am posting here the coding for my form showing the output also here:
@
#include "user_data.h"
#include "ui_user_data.h"
#include"mydialog28.h"
user_data::user_data(QWidget *parent) :
QDialog(parent),
ui(new Ui::user_data)
{
ui->setupUi(this);
}user_data::~user_data()
{
db.close();
delete ui;
}void user_data::on_pushButton_clicked()
{
MyDialog28 m;
m.exec();
}void user_data::on_pushButton_2_clicked()
{}
void user_data::on_pushButton_3_clicked()
{
QSqlDatabase db= QSqlDatabase::addDatabase("QSQLITE");
db.setDatabaseName("prject3");
db.open();
this->model= new QSqlQueryModel();
model->setQuery("select * from tab1");
ui->tableView->setModel(model);
}
@
please help me out on how i can store a value of text entered through line edit into my backend database.[Edit: @ tags; mlong]
-
sure sir. i will. please tell the solution to my problem.
-
bq. please tell the solution to my problem
I don't have an answer, myself, but I promise that making demands such as that is considered rude and will not help you get an answer faster.
Please see http://www.catb.org/~esr/faqs/smart-questions.html for advice on how to get the best results. Thanks.
-
sorry sir for my bit of impatient behavior. i had absolutely no intention like this. i have actually tried out the suggestions posted. they actually did not work.
-
Try the below
@
QString name= ui->lineEdit_14->text();
QString branch= ui->lineEdit_13->text();
QString date= ui->lineEdit_15->text();
QString cnct =ui->lineEdit_16->text();
QString email= ui->lineEdit_17->text();
QString addrss= ui->lineEdit_18->text();
QString query = QString("INSERT INTO 'tab1' VALUES('%1','%2','%3','%4','%5','%6')").arg(name).arg(branch).arg(date).arg(cnct).arg(email).arg(addrss);
q.exec( query );
@I would strongly suggest you to go through the documentation for "QString":http://qt-project.org/doc/qt-4.8/QString.html. Infact you can click on the source code [highlighted with GREEN color] to go to the documentation page.
-
thank you sir. the code has worked. i was actually having a problem that i was trying to connect to the database using same connection that i have used ahead in my project. i had to change the connection also. now the code works fine.
-
sure. i do it now