Hi everybody, I'm writing a program with QT 4.4
I'm writing a program to read email from a SQLite database, I used a QSqlQueryModel and a QTableView, when I select a row of the table it returns a QModelIndex
connect(myTable, SIGNAL(clicked(QModelIndex)),myTextBrowser, SLOT(dispayMail(QModelIndex)));
To copy to clipboard, switch view to plain text mode
I want that instead a QModelIndex it returns the email id, or else, how i get the email id from the QModelIndex?
Here is the code: (just a part of it, if you need more I will post it)
QSqlQuery query
("SELECT email.id,addresses.name,email.subject,email.date FROM email,addresses WHERE addresses.id=email.'from'");
model->setQuery(query);
model->removeColumn(0); // don't show the ID
model->setHeaderData(0, Qt::Horizontal, tr("Da"));
model->setHeaderData(1, Qt::Horizontal, tr("Soggetto"));
model->setHeaderData(2, Qt::Horizontal, tr("Data"));
this->setShowGrid(FALSE);
this->verticalHeader()->hide();
this->setModel(model);
this->show();
QSqlQuery query("SELECT email.id,addresses.name,email.subject,email.date FROM email,addresses WHERE addresses.id=email.'from'");
model = new QSqlQueryModel;
model->setQuery(query);
model->removeColumn(0); // don't show the ID
model->setHeaderData(0, Qt::Horizontal, tr("Da"));
model->setHeaderData(1, Qt::Horizontal, tr("Soggetto"));
model->setHeaderData(2, Qt::Horizontal, tr("Data"));
this->setShowGrid(FALSE);
this->verticalHeader()->hide();
this->setEditTriggers(QAbstractItemView::NoEditTriggers);
this->setSelectionMode(QAbstractItemView::ContiguousSelection);
this->setSelectionBehavior(QAbstractItemView::SelectRows);
this->setSelectionMode(QAbstractItemView::ExtendedSelection);
this->setModel(model);
this->show();
To copy to clipboard, switch view to plain text mode
Thanks
Ps: Sorry for my english, but I'm swiss
Bookmarks