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] update the view
Forum Updated to NodeBB v4.3 + New Features

[Solved] update the view

Scheduled Pinned Locked Moved General and Desktop
9 Posts 2 Posters 2.3k 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.
  • Y Offline
    Y Offline
    yakine
    wrote on last edited by
    #1

    hello
    i have a qtableview witch display data from a database table by using qsqltablemodel when clicked on a row of this tableview another window open in this window i have a button when clicked this button the data of the database table is update when i close the window after updating i found that the view was not update i want that the view update
    please help me

    IF YOU HAVE MERCY ON PEOPLE GOD HAVE MERCY ON YOU

    1 Reply Last reply
    0
    • Chris KawaC Offline
      Chris KawaC Offline
      Chris Kawa
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Have you tried to call "select()":http://qt-project.org/doc/qt-5/qsqltablemodel.html#select on the model to update the view?

      Btw. Please use punctuation and capital letters where needed. It's really hard to read like that.

      1 Reply Last reply
      0
      • Y Offline
        Y Offline
        yakine
        wrote on last edited by
        #3

        thank you chris kawa

        Sorry for my bad English
        so i have atable in may database called patient this
        i used qsqltable model like this
        @model.settable("patient");
        model.select();
        ui.tableview.setmodal(true);@ to view the modal and every thing is going good
        iused the slot on table view clicked when users click on it a window open in this window i have a button that when user click on it the data of a spesific row of the table patient will be update
        when i close this window after updating i found that information don't update in the previous qtable view

        IF YOU HAVE MERCY ON PEOPLE GOD HAVE MERCY ON YOU

        1 Reply Last reply
        0
        • Chris KawaC Offline
          Chris KawaC Offline
          Chris Kawa
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Yes, try to call model.select() again, after you come back from the dialog.

          I didn't mean your english, I'm not a native speaker either. I meant separate your sentences with punctuation: ,.:; etc.

          1 Reply Last reply
          0
          • Y Offline
            Y Offline
            yakine
            wrote on last edited by
            #5

            ok thank you
            but i don't understand how can i call it after i come back from th dialog
            Especially where?

            IF YOU HAVE MERCY ON PEOPLE GOD HAVE MERCY ON YOU

            1 Reply Last reply
            0
            • Chris KawaC Offline
              Chris KawaC Offline
              Chris Kawa
              Lifetime Qt Champion
              wrote on last edited by
              #6

              There are couple of ways. For example in the closeEvent of your dialog you can emit a custom signal. connect() the select() slot of the model to that signal and you're done.

              1 Reply Last reply
              0
              • Y Offline
                Y Offline
                yakine
                wrote on last edited by
                #7

                @void consultation::closeEvent(QCloseEvent *)
                {

                // initialisation des cocher bilan
                
                QSqlQuery requete;
                requete.exec("UPDATE dictionnairebilan SET varplus=''");
                

                afficherRDV r;
                r.ui->pushButton_2->clicked(true);

                }

                void afficherRDV::on_pushButton_2_clicked()
                {

                // renouvelement de l'affichage normalement radha fonction
                 QString numDP,nomPrenomDP;
                  numDP=ui->nRechercherDP->text();
                  nomPrenomDP= ui->nomRchercherP ->text();
                
                    if(numDP == "" && nomPrenomDP == "")
                    {
                    QSqlQueryModel*model=new QSqlQueryModel();
                    QSqlQuery *rr=new QSqlQuery();
                    rr->exec("SELECT * FROM patient ");
                    model->setQuery(*rr);
                    ui->listPatient->setModel(model);
                
                    qDebug()<<(model->rowCount());
                    qDebug()<< "you are in the first part hhhh";
                    }
                    else if( nomPrenomDP!=""  )
                    {
                
                        const QString str1=ui->nomRchercherP->text();
                        on_nomRchercherP_textChanged(str1);
                        qDebug()<<str1<<"you are in the second part";
                    }
                    else if( numDP!="")
                       {
                
                        const QString str2=ui->nRechercherDP->text();
                        on_nRechercherDP_textChanged(str2);
                        qDebug()<<str2<<"you are in te third part";
                       }
                

                }
                @ but it still the same broblem

                IF YOU HAVE MERCY ON PEOPLE GOD HAVE MERCY ON YOU

                1 Reply Last reply
                0
                • Chris KawaC Offline
                  Chris KawaC Offline
                  Chris Kawa
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  This code doesn't look right.
                  [quote author="yakine" date="1402765677"]r.ui->pushButton_2->clicked(true);[/quote]
                  That's not how you emit a signal.

                  Assuming you've got class SomeClass that has the model as member myModel and a second window SomeWidget as a member someWidget:

                  Define a custom signal in the SomeWidget class and emit it from the close event:
                  @
                  SomeWidget {
                  ...
                  signals:
                  void myCustomSignal();
                  public:
                  void closeEvent(QCloseEvent* evt) {
                  emit myCustomSignal();
                  }
                  }
                  @
                  In your SomeClass connect that signal to the model select() slot somewhere eg. in the constructor:
                  @
                  SomeClass::SomeClass() {
                  ...
                  connect(someWidget, &SomeWidget::myCustomSignal, myModel, &QSqlTableModel::select);
                  }
                  @

                  1 Reply Last reply
                  0
                  • Y Offline
                    Y Offline
                    yakine
                    wrote on last edited by
                    #9

                    thank you and sorry Chris kawa

                    the problem it solved thank you again

                    IF YOU HAVE MERCY ON PEOPLE GOD HAVE MERCY ON YOU

                    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