Kesy
30th October 2008, 07:43
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)));
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 = 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::ContiguousSele ction);
this->setSelectionBehavior(QAbstractItemView::SelectRows );
this->setSelectionMode(QAbstractItemView::ExtendedSelect ion);
this->setModel(model);
this->show();
Thanks
Ps: Sorry for my english, but I'm swiss :)
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)));
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 = 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::ContiguousSele ction);
this->setSelectionBehavior(QAbstractItemView::SelectRows );
this->setSelectionMode(QAbstractItemView::ExtendedSelect ion);
this->setModel(model);
this->show();
Thanks
Ps: Sorry for my english, but I'm swiss :)