How can I manage to somehow autoupdate a QTableView that returns data from a MySQL Table trough a QSqlQueryModel.
I add the data into the database from two QlineEdit.
//casuta dreapta jos
QLabel *added_table_label
= new QLabel(tr
("Lista websiteuri"));
added_sites->setFixedWidth(500);
added_sites->setModel(inputlista);
added_sites->setColumnWidth(0,245);
added_sites->setColumnWidth(1,245);
added_sites->show();
lista_websiteuri->addWidget(added_table_label);
lista_websiteuri->addWidget(added_sites);
//casuta dreapta jos
QLabel *added_table_label = new QLabel(tr("Lista websiteuri"));
QTableView *added_sites = new QTableView;
QSqlQueryModel *inputlista = db.show_table_sites();
added_sites->setFixedWidth(500);
added_sites->setModel(inputlista);
added_sites->setColumnWidth(0,245);
added_sites->setColumnWidth(1,245);
added_sites->show();
QVBoxLayout *lista_websiteuri = new QVBoxLayout;
lista_websiteuri->addWidget(added_table_label);
lista_websiteuri->addWidget(added_sites);
To copy to clipboard, switch view to plain text mode
void window::addsite()
{
web_address = this->website_add->text();
email_address = this->email_add->text();
string adresaw=web_address.toStdString();
const char *argument_site=adresaw.c_str();
string adresae=email_address.toStdString();
const char *argument_email=adresae.c_str();
db.addtolist(contorsite, argument_site, argument_email);
website_add->clear();
email_add->clear();
contorsite++;
}
void window::addsite()
{
web_address = this->website_add->text();
email_address = this->email_add->text();
string adresaw=web_address.toStdString();
const char *argument_site=adresaw.c_str();
string adresae=email_address.toStdString();
const char *argument_email=adresae.c_str();
db.addtolist(contorsite, argument_site, argument_email);
website_add->clear();
email_add->clear();
contorsite++;
}
To copy to clipboard, switch view to plain text mode
Bookmarks