aurora
29th May 2012, 09:45
I am using QSqlQuerModel in my program and using table view to display the contents of the model.
But when i set the model nothing displays in the table other than two brown lines at the horizontal and verticla headers.....
my program code....
void win::on_pushButton_clicked()
{
QStringList signalList;
QString filename;
filename="C:/Users/Desktop/abc.txt";
headersList=GetheaderNames(filename);
QFileInfo file(filename);
createTable(file.baseName(),headersList);
GetFileContent(filename);
QSqlQueryModel plainModel2;
initializeModel(&plainModel2,file.baseName(),headersList);
ui->tableView_2->setModel(&plainModel2);
}
initialiseModel function
void initializeModel(QSqlQueryModel *model,QString filename, QStringList headersList)
{
QString queryString=QString("select * from %1").arg(filename);
model->setQuery(queryString);
for(int i=0;i<headersList.count();i++)
{
model->setHeaderData(i, Qt::Horizontal, (headersList.at(i)));
}
}
plz help me to sort out the problm here!!
But when i set the model nothing displays in the table other than two brown lines at the horizontal and verticla headers.....
my program code....
void win::on_pushButton_clicked()
{
QStringList signalList;
QString filename;
filename="C:/Users/Desktop/abc.txt";
headersList=GetheaderNames(filename);
QFileInfo file(filename);
createTable(file.baseName(),headersList);
GetFileContent(filename);
QSqlQueryModel plainModel2;
initializeModel(&plainModel2,file.baseName(),headersList);
ui->tableView_2->setModel(&plainModel2);
}
initialiseModel function
void initializeModel(QSqlQueryModel *model,QString filename, QStringList headersList)
{
QString queryString=QString("select * from %1").arg(filename);
model->setQuery(queryString);
for(int i=0;i<headersList.count();i++)
{
model->setHeaderData(i, Qt::Horizontal, (headersList.at(i)));
}
}
plz help me to sort out the problm here!!