Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [Solved] Closing a dialog with a timer.
Forum Updated to NodeBB v4.3 + New Features

[Solved] Closing a dialog with a timer.

Scheduled Pinned Locked Moved General and Desktop
16 Posts 4 Posters 12.5k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    guptaprashant1986gmail
    wrote on last edited by
    #7

    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]

    1 Reply Last reply
    0
    • M Offline
      M Offline
      mlong
      wrote on last edited by
      #8

      When posting code, please wrap it in @ tags to preserve its formatting.

      Software Engineer
      My views and opinions do not necessarily reflect those of anyone -- living or dead, real or fictional -- in this universe or any other similar multiverse node. Void where prohibited. Your mileage may vary. Caveat emptor.

      1 Reply Last reply
      0
      • G Offline
        G Offline
        guptaprashant1986gmail
        wrote on last edited by
        #9

        sure sir. i will. please tell the solution to my problem.

        1 Reply Last reply
        0
        • M Offline
          M Offline
          mlong
          wrote on last edited by
          #10

          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.

          Software Engineer
          My views and opinions do not necessarily reflect those of anyone -- living or dead, real or fictional -- in this universe or any other similar multiverse node. Void where prohibited. Your mileage may vary. Caveat emptor.

          1 Reply Last reply
          0
          • G Offline
            G Offline
            guptaprashant1986gmail
            wrote on last edited by
            #11

            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.

            1 Reply Last reply
            0
            • V Offline
              V Offline
              veeraps
              wrote on last edited by
              #12

              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.

              1 Reply Last reply
              0
              • G Offline
                G Offline
                guptaprashant1986gmail
                wrote on last edited by
                #13

                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.

                1 Reply Last reply
                0
                • V Offline
                  V Offline
                  veeraps
                  wrote on last edited by
                  #14

                  Appreciate if you could edit the Topic and add [SOLVED] in the front to say that this thread is completed.

                  1 Reply Last reply
                  0
                  • G Offline
                    G Offline
                    guptaprashant1986gmail
                    wrote on last edited by
                    #15

                    sure. i do it now

                    1 Reply Last reply
                    0
                    • G Offline
                      G Offline
                      gdouglas7
                      wrote on last edited by
                      #16

                      I always tried so very helpful

                      Qt Developer
                      Student of Information System

                      1 Reply Last reply
                      0

                      • Login

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • Users
                      • Groups
                      • Search
                      • Get Qt Extensions
                      • Unsolved